1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Merge pull request #10237 from cgocast/5.x

Loop over PDOStatement::fetch() arguments
This commit is contained in:
orklah 2023-09-28 23:03:26 +02:00 committed by GitHub
commit e110305644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,12 +49,16 @@ class PdoStatementReturnTypeProvider implements MethodReturnTypeProviderInterfac
$source = $event->getSource();
$call_args = $event->getCallArgs();
$fetch_mode = 0;
if (isset($call_args[0])
&& ($first_arg_type = $source->getNodeTypeProvider()->getType($call_args[0]->value))
&& $first_arg_type->isSingleIntLiteral()
) {
$fetch_mode = $first_arg_type->getSingleIntLiteral()->value;
foreach ($call_args as $call_arg) {
$arg_name = $call_arg->name;
if (!isset($arg_name) || $arg_name->name === "mode") {
$arg_type = $source->getNodeTypeProvider()->getType($call_arg->value);
if (isset($arg_type) && $arg_type->isSingleIntLiteral()) {
$fetch_mode = $arg_type->getSingleIntLiteral()->value;
}
break;
}
}
switch ($fetch_mode) {