-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fix string|float-to-int convertion errors #1271
Fix string|float-to-int convertion errors #1271
Conversation
07c69d9
to
5925114
Compare
There were 3 major errors: - int fields from the DB that are returned as string by mysqli. - date('s|d|y|U') that returns a int as a string. - PHP float truncating functions that returns a float.
5925114
to
24c7ef3
Compare
@@ -24,7 +24,7 @@ parameters: | |||
path: pinc/3rdparty/mediawiki/DairikiDiff.php | |||
- message: '#Comparison operation .* results in an error#' | |||
path: pinc/3rdparty/mediawiki/DiffEngine.php | |||
- message: '#^Parameter \#2 \$num of function array_fill expects int, float given\.$#' | |||
- message: '#^Parameter \#2 \$.* of function array_fill expects int, float given\.$#' |
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.
That's a small mistake I made in the previous PR that makes PHPStan fails: PHP 8 does actually see the error but with a different parameter name.
$foo_Header, | ||
$foo_field_name, | ||
$blather | ||
string $id, |
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 added this type to prove that that the $id
parameter is a string and thus we need to manually ignore some issue in PHPStan on pinc/stages.inc
.
The other types in the constructors were added bonuses.
All the types are copied from the class member's.
@@ -307,7 +307,7 @@ new Stage( | |||
// ----------------------------------------------------------------------------- | |||
|
|||
new Pool( | |||
'PPV', | |||
'PPV', // @phpstan-ignore-line PHPStan 1.10 reports a string-to-int conv here, seems like a bug |
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.
is it worth setting up a minimal example and creating an issue against phpstan?
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.
Yes, I just did! Also the reproduction showed that the issue is that we reuse the name Pool
that exists in the PHP standard library and confuses PHPStan:
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.
That's awesome, thanks.
There were 3 major errors:
Update by cpeel: Sandbox avail at https://www.pgdp.org/~cpeel/c.branch/julien_fix_int_to_str_conv/