-
Notifications
You must be signed in to change notification settings - Fork 7.9k
mysqli_field_seek return type changed to true #11948
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
mysqli_field_seek return type changed to true #11948
Conversation
Is |
Can you explain a little more? Is this true even with |
So using tentative return types would force implementations to return |
Yes, George is right: I didn't add any kind of type declaration because of the possible migration to |
1b0ead5
to
37f8a42
Compare
Thanks for explanation. The second commit is dropped. |
@@ -1457,7 +1457,7 @@ function mysqli_fetch_column(mysqli_result $result, int $column = 0): null|int|f | |||
|
|||
function mysqli_field_count(mysqli $mysql): int {} | |||
|
|||
function mysqli_field_seek(mysqli_result $result, int $index): bool {} | |||
function mysqli_field_seek(mysqli_result $result, int $index): true {} // TODO make return type void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its alias should also be adjusted, otherwise ./build/gen_stub.php --verify
will emit an error:
mysqli_result::field_seek() and mysqli_field_seek() must have the same return type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And how do I fix it without adding true
return type to the method? Would @return true
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the return type to true. Maybe we should change it straight away to void?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is true
to void
is a BC break as a void
function returns null
so if the return value of the function is used and compared against, a different code path will then be taken.
37f8a42
to
37e5c25
Compare
Would be nice to have this correct in PHP-8.0 and newer branches, not just for PHP 8.3. For example |
We did not have return type |
8.0 is out of support, and the And yes, the stubs reflect reality that's the whole point of them. If the stubs are wrong by having a return type that is too narrow or a parameter type that is too wide we have some major issues. So for PHPStan for version 8.0 and 8.1 for the most part you will need to have a sort of registry to inform about the "effective" return type of those functions, which then can include minor fixes for 8.2 too. |
Alright, nice, thanks.
In phpstan/php-8-stubs where I extract the stubs, I check out each branch separately and then merge the definitions, like this: https://github.com/phpstan/php-8-stubs/blob/main/stubs/ext/mysqli/mysqli_close.php So as long as each php-src branch has the correct data, it's fine for me as well 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an UPGRADING note and LGTM
f13efb7
to
44f394d
Compare
mysqli_field_seek
should have been marked as returning true in PHP 8.2.@kocsismate Is there a reason why the methods cannot have true type? I can't remember. I will drop the second commit if that's not possible.