mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Do not provide mixed return type on unrelated methods (#5895)
Fixes vimeo/psalm#5894
This commit is contained in:
parent
3ad3375777
commit
a5080f2cf6
@ -16,14 +16,18 @@ class DomNodeAppendChild implements \Psalm\Plugin\EventHandler\MethodReturnTypeP
|
||||
$source = $event->getSource();
|
||||
$call_args = $event->getCallArgs();
|
||||
$method_name_lowercase = $event->getMethodNameLowercase();
|
||||
|
||||
if ($method_name_lowercase !== 'appendchild') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer
|
||||
|| !$call_args
|
||||
) {
|
||||
return Type::getMixed();
|
||||
}
|
||||
|
||||
if ($method_name_lowercase === 'appendchild'
|
||||
&& ($first_arg_type = $source->node_data->getType($call_args[0]->value))
|
||||
if (($first_arg_type = $source->node_data->getType($call_args[0]->value))
|
||||
&& $first_arg_type->hasObjectType()
|
||||
) {
|
||||
return clone $first_arg_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user