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:
parent
9b4c8cb53f
commit
e751a27eaf
@ -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;
|
||||
|
@ -391,6 +391,16 @@ class AttributeTest extends TestCase
|
||||
class Bar {}
|
||||
',
|
||||
],
|
||||
'dontCrashWhenRedefiningStubbedMethodWithFewerParams' => [
|
||||
'<?php
|
||||
if (!class_exists(ArrayObject::class)) {
|
||||
class ArrayObject
|
||||
{
|
||||
public function __construct() {}
|
||||
}
|
||||
}
|
||||
'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user