Skip to content

Use "numeric-string" type for some MySQLi functions #2223

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

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

phansys
Copy link
Contributor

@phansys phansys commented Feb 6, 2023

If the number of rows is greater than PHP_INT_MAX, the number will be returned as a string.

BTW, is there a way to declare the type for properties like mysqli_stmt::$affected_rows?

Related to #1116.

@phansys phansys marked this pull request as ready for review February 6, 2023 10:34
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@@ -7272,7 +7272,7 @@
'mysqli_multi_query' => ['bool', 'link'=>'mysqli', 'query'=>'string'],
'mysqli_next_result' => ['bool', 'link'=>'mysqli'],
'mysqli_num_fields' => ['int', 'link'=>'mysqli_result'],
'mysqli_num_rows' => ['int', 'link'=>'mysqli_result'],
'mysqli_num_rows' => ['int<-1,max>|numeric-string', 'link'=>'mysqli_result'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it's -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I just copied the type from mysqli_affected_rows. It's fixed.

@ondrejmirtes
Copy link
Member

BTW, is there a way to declare the type for properties

Try to add a stub file, but please add a test for it too (NodeScopeResolverTest), it might be buggy.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
renovate-bot Mend Renovate
@ondrejmirtes
Copy link
Member

Thank you.

@ondrejmirtes ondrejmirtes merged commit b58d93e into phpstan:1.10.x Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants