mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Resolve tests for StaticInvocation and NonStaticSelfCall
The code has been moved from down to up. Resolved problems: ``` 1) MagicMethodAnnotationTest::testInvalidCode with data set "staticInvocationWithInstanceMethodFoo" Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown. 2) MagicMethodAnnotationTest::testInvalidCode with data set "nonStaticSelfCallWithInstanceMethodFoo" Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown. ```
This commit is contained in:
parent
6f17469b24
commit
4c645e186c
@ -567,6 +567,39 @@ final class AtomicStaticCallAnalyzer
|
||||
$with_pseudo = $callstatic_method_exists
|
||||
|| $codebase->config->use_phpdoc_method_without_magic_or_parent;
|
||||
|
||||
if ($codebase->methods->getDeclaringMethodId($method_id, $with_pseudo)) {
|
||||
if ((!$stmt->class instanceof PhpParser\Node\Name
|
||||
|| $stmt->class->getFirst() !== 'parent'
|
||||
|| $statements_analyzer->isStatic())
|
||||
&& (
|
||||
!$context->self
|
||||
|| $statements_analyzer->isStatic()
|
||||
|| !$codebase->classExtends($context->self, $fq_class_name)
|
||||
)
|
||||
) {
|
||||
MethodAnalyzer::checkStatic(
|
||||
$method_id,
|
||||
($stmt->class instanceof PhpParser\Node\Name
|
||||
&& strtolower($stmt->class->getFirst()) === 'self')
|
||||
|| $context->self === $fq_class_name,
|
||||
!$statements_analyzer->isStatic(),
|
||||
$codebase,
|
||||
new CodeLocation($statements_analyzer, $stmt),
|
||||
$statements_analyzer->getSuppressedIssues(),
|
||||
$is_dynamic_this_method,
|
||||
);
|
||||
|
||||
if ($is_dynamic_this_method) {
|
||||
return self::forwardCallToInstanceMethod(
|
||||
$statements_analyzer,
|
||||
$stmt,
|
||||
$stmt_name,
|
||||
$context,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$naive_method_exists
|
||||
|| !MethodAnalyzer::isMethodVisible(
|
||||
$method_id,
|
||||
@ -831,37 +864,6 @@ final class AtomicStaticCallAnalyzer
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!$stmt->class instanceof PhpParser\Node\Name
|
||||
|| $stmt->class->getFirst() !== 'parent'
|
||||
|| $statements_analyzer->isStatic())
|
||||
&& (
|
||||
!$context->self
|
||||
|| $statements_analyzer->isStatic()
|
||||
|| !$codebase->classExtends($context->self, $fq_class_name)
|
||||
)
|
||||
) {
|
||||
MethodAnalyzer::checkStatic(
|
||||
$method_id,
|
||||
($stmt->class instanceof PhpParser\Node\Name
|
||||
&& strtolower($stmt->class->getFirst()) === 'self')
|
||||
|| $context->self === $fq_class_name,
|
||||
!$statements_analyzer->isStatic(),
|
||||
$codebase,
|
||||
new CodeLocation($statements_analyzer, $stmt),
|
||||
$statements_analyzer->getSuppressedIssues(),
|
||||
$is_dynamic_this_method,
|
||||
);
|
||||
|
||||
if ($is_dynamic_this_method) {
|
||||
return self::forwardCallToInstanceMethod(
|
||||
$statements_analyzer,
|
||||
$stmt,
|
||||
$stmt_name,
|
||||
$context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$has_existing_method = true;
|
||||
|
||||
ExistingAtomicStaticCallAnalyzer::analyze(
|
||||
|
Loading…
x
Reference in New Issue
Block a user