Skip to content

Commit 8471a89

Browse files
authored
Merge pull request #10812 from issidorov/bug-10807
2 parents 005e318 + fe42e88 commit 8471a89

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ private static function handleNamedCall(
789789
}
790790
}
791791

792-
if (!$callstatic_method_exists || $class_storage->hasSealedMethods($config)) {
792+
if ($naive_method_exists || !$callstatic_method_exists || $class_storage->hasSealedMethods($config)) {
793793
$does_method_exist = MethodAnalyzer::checkMethodExists(
794794
$codebase,
795795
$method_id,

tests/AssertAnnotationTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,36 @@ function requiresString(string $_str): void {}
9090
$this->analyzeFile('somefile.php', new Context());
9191
}
9292

93+
public function testAssertsAllongCallStaticMethodWork(): void
94+
{
95+
$this->addFile(
96+
'somefile.php',
97+
'<?php
98+
99+
class ImportedAssert
100+
{
101+
/** @psalm-assert non-empty-string $b */
102+
public static function notEmptyStrOnly(string $b): void
103+
{
104+
if ("" === $b) throw new \Exception("");
105+
}
106+
107+
public function __callStatic() {}
108+
}
109+
110+
/** @return non-empty-string */
111+
function returnNonEmpty(string $b): string
112+
{
113+
ImportedAssert::notEmptyStrOnly($b);
114+
115+
return $b;
116+
}
117+
',
118+
);
119+
120+
$this->analyzeFile('somefile.php', new Context());
121+
}
122+
93123
public function testAssertInvalidDocblockMessageDoesNotIncludeTrace(): void
94124
{
95125
$this->expectException(CodeException::class);

0 commit comments

Comments
 (0)