-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP Deprecated: Return type of Requests_* on 8.1 with PHPStan #41
Comments
Hello Daniele! Here are a few statements for you.
This is an automatically generated repo. |
I was thinking of a bash script with sed that will look for the comment (for all of these functions) that will replace adding that comment. |
#!/usr/bin/env bash
function append_flag() {
lines=$(awk "/$1/{print FNR}" ./wordpress-stubs.php)
i=0
for line in $lines
do
echo "Found line $line"
line=$((line+i))
if ! [ -z "$2" ]; then
line=$((line+$2))
fi
sed -i $line"i #[\\ReturnTypeWillChange]" ./wordpress-stubs.php
echo "Appended to line $line"
# The line number change after the first insertion
i=$((i+1))
done
}
append_flag 'public function unserialize\(\$serialized\)'
append_flag 'public function __unserialize\(\$serialized\)'
append_flag "* Get the current item's value after filtering" 4
append_flag 'public function offsetExists\(\$key\)'
append_flag 'public function offsetGet\(\$key\)'
append_flag 'public function offsetSet\(\$key, \$value\)'
append_flag 'public function offsetUnset\(\$key\)'
append_flag 'public function getIterator\(\)' This bash script fix the stubs and add the flag on the methods reported and now everything is clean :-) The only issue is that is no indentation also if I tried for that but I don't think that is a problem. Do you want a PR? How I can name the script? |
Thank you!
Do you mean these functions appear more than once? |
Yes there are methods with the same name that have the same issues in the Request library, this way we fix it with a single line |
We should create a file similar to https://github.com/php-stubs/wordpress-stubs/blob/master/functionMap.php Line 37 in e04781a
|
I don't have time now to convert it in PHP code. I see that the https://github.com/php-stubs/wordpress-stubs/blob/master/generate.sh#L33 file already do some manipulation by bash so maybe we can add that code there. |
I'm still seeing this issue in the latest version. I see the PR was closed... Is there a reason the issue is closed? |
The individual notices I am still seeing:
|
Hello Benjamin! 👋🏻 These problems have been fixed a year ago in the next release of Requests: WordPress/Requests#505 Feel free to send a PR that completes that closed PR. |
Although I suggest you to ignore these in a human way (by not looking at your screen) as PHPStan cannot ignore deprecations. |
Fixed in #53 |
Manually including the latest version of the |
With PHP 8.1 I am getting all those warning. I know that WP itself doesn't support that version but they are very annoying so I wasn't sure if it was to fix there instead on the phpstan-wordpress package.
Maybe it is possible to add
#[\ReturnTypeWillChange]
comment on the stubs for those methods so this error is silenced until WP support that version.The text was updated successfully, but these errors were encountered: