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

Fix crash when redefining method with fewer params (fixes #8141).

This commit is contained in:
AndrolGenhald 2022-06-26 06:27:46 -05:00
parent 9b4c8cb53f
commit e751a27eaf
2 changed files with 21 additions and 9 deletions

View File

@ -1267,15 +1267,17 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
$context->hasVariable('$' . $function_param->name);
}
AttributesAnalyzer::analyze(
$this,
$context,
$function_param,
$param_stmts[$offset]->attrGroups,
AttributesAnalyzer::TARGET_PARAMETER
| ($function_param->promoted_property ? AttributesAnalyzer::TARGET_PROPERTY : 0),
$storage->suppressed_issues + $this->getSuppressedIssues()
);
if (count($param_stmts) === count($params)) {
AttributesAnalyzer::analyze(
$this,
$context,
$function_param,
$param_stmts[$offset]->attrGroups,
AttributesAnalyzer::TARGET_PARAMETER
| ($function_param->promoted_property ? AttributesAnalyzer::TARGET_PROPERTY : 0),
$storage->suppressed_issues + $this->getSuppressedIssues()
);
}
}
return $check_stmts;

View File

@ -391,6 +391,16 @@ class AttributeTest extends TestCase
class Bar {}
',
],
'dontCrashWhenRedefiningStubbedMethodWithFewerParams' => [
'<?php
if (!class_exists(ArrayObject::class)) {
class ArrayObject
{
public function __construct() {}
}
}
'
],
];
}