Repository navigation
Add fetch_column/fetch_object/fetch_row methods & mysqli_fetch_all func - #827
Conversation
| * @param list<ParametersAcceptor> $variants | ||
| */ | ||
| private function getExprObjectType(Scope $scope, Expr $expr): ?Type | ||
| private function getArgOrDefault(array $variants, CallLike $call, Scope $scope, int $i): Type |
There was a problem hiding this comment.
please add tests to show proof this method also works properly for calls with named arguments
There was a problem hiding this comment.
Done. I added this just for {mysqli_,}fetch_column because named arguments are a syntax error in PHP 7.4 so we can't extend the tests in tests/default/data/mysqli.php , and the same mechanism used for fetch_column is used for fetch_all.
There was a problem hiding this comment.
Actually never mind the previous comment. The linter forced me to move all the named argument tests into a separate file, so I tested everything.
a122bf6 to
2d18e84
Compare
| if (! $hasOffset->yes()) { | ||
| return [ | ||
| RuleErrorBuilder::message(sprintf( | ||
| 'Column offset %s may be out of range; valid offsets are %s.', | ||
| $columnType->describe(VerbosityLevel::value()), | ||
| $numericRowType->getIterableKeyType()->describe(VerbosityLevel::value()), | ||
| )) | ||
| ->identifier('dba.columnOffset') | ||
| ->line($columnArg->value->getStartLine()) | ||
| ->build(), | ||
| ]; | ||
| } |
There was a problem hiding this comment.
this handling should depend on "reportMaybe" (so the phpstan level), as in e.g. https://github.com/phpstan/phpstan-src/blob/ec03c848556e234672ab70d1a343cab6800f7353/src/Rules/Functions/CallCallablesRule.php#L39-L40
I would prefer we keep the new rule in a separate PR to ease reviewing
There was a problem hiding this comment.
ACK. I'll move it out into a separate PR
38aafd3 to
ca27a69
Compare
|
thank you! |
No description provided.