mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
parent
2b7cd6b303
commit
7b03e0159c
@ -413,8 +413,9 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($stmt->class instanceof PhpParser\Node\Name
|
||||
&& ($stmt->class->parts[0] !== 'parent' || $statements_analyzer->isStatic())
|
||||
if ((!$stmt->class instanceof PhpParser\Node\Name
|
||||
|| $stmt->class->parts[0] !== 'parent'
|
||||
|| $statements_analyzer->isStatic())
|
||||
&& (
|
||||
!$context->self
|
||||
|| $statements_analyzer->isStatic()
|
||||
@ -423,7 +424,9 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
||||
) {
|
||||
if (MethodAnalyzer::checkStatic(
|
||||
$method_id,
|
||||
strtolower($stmt->class->parts[0]) === 'self' || $context->self === $fq_class_name,
|
||||
($stmt->class instanceof PhpParser\Node\Name
|
||||
&& strtolower($stmt->class->parts[0]) === 'self')
|
||||
|| $context->self === $fq_class_name,
|
||||
!$statements_analyzer->isStatic(),
|
||||
$codebase,
|
||||
new CodeLocation($source, $stmt),
|
||||
|
@ -435,6 +435,15 @@ class MethodCallTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'UndefinedMethod - src/somefile.php:7 - Method (B&A)::zugzug does not exist'
|
||||
],
|
||||
'noInstanceCallAsStatic' => [
|
||||
'<?php
|
||||
class C {
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
(new C)::foo();',
|
||||
'error_message' => 'InvalidStaticInvocation',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user