-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
PHPStan 1.0.2 #4943
PHPStan 1.0.2 #4943
Conversation
- | ||
message: '~^Parameter #2 \$count of function array_fill expects int<0, max>, int given\.$~' | ||
message: '~Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::rowCount\(\) should return int but returns int\|string\.~' |
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.
@morozov This error seems to be raised because of the stub you contributed in phpstan/phpstan-src#700.
The mysqli_stmt::$affected_rows
property is documented as int|string
which is also what the documentation on php.net says. The documentation does not say in which cases we can expect a string here, but my guess is that this happens if the number of affected rows is larger than PHP_INT_MAX
.
However, this also applies to mysqli_stmt::$num_rows
which your stub documents as 0|positive-int
.
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.
So the stub probably should be 0|positive-int|string
, as well as the return type in the DBAL driver.
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.e. we also need to change the @return
annotation on (Statement|Result)::rowCount()
from int
to int|string
because it will return a string if the value is greater than PHP_INT_MAX
.
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.
This is a bit of a problem because on 3.1.x, we already have an int
return type declaration.
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 see. Then I think it's acceptable. Unlike the discussion in doctrine/orm#8963 (comment), updating or deleting a number of rows larger than PHP_INT_MAX
is close to impossible.
c6e163f
to
52eb197
Compare
52eb197
to
2dc8ff1
Compare
- | ||
message: '~^Parameter #2 \$count of function array_fill expects int<0, max>, int given\.$~' | ||
message: '~Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::rowCount\(\) should return int but returns int\|string\.~' |
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.
So the stub probably should be 0|positive-int|string
, as well as the return type in the DBAL driver.
6362aff
to
255ad58
Compare
8e21a5d
to
a39bfc8
Compare
Signed-off-by: Alexander M. Turek <me@derrabus.de>
a39bfc8
to
fd088f1
Compare
Thanks @derrabus ! |
Summary
I've bumped PHPStan to the new 1.0.0 and made the necessary adjustments.
I've also tried out the new level 9 and decided that we probably can live with level 8 on old branches. 😇