Skip to content

Commit

Permalink
Merge pull request #10812 from issidorov/bug-10807
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan authored Mar 11, 2024
2 parents 005e318 + fe42e88 commit 8471a89
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ private static function handleNamedCall(
}
}

if (!$callstatic_method_exists || $class_storage->hasSealedMethods($config)) {
if ($naive_method_exists || !$callstatic_method_exists || $class_storage->hasSealedMethods($config)) {
$does_method_exist = MethodAnalyzer::checkMethodExists(
$codebase,
$method_id,
Expand Down
30 changes: 30 additions & 0 deletions tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,36 @@ function requiresString(string $_str): void {}
$this->analyzeFile('somefile.php', new Context());
}

public function testAssertsAllongCallStaticMethodWork(): void
{
$this->addFile(
'somefile.php',
'<?php
class ImportedAssert
{
/** @psalm-assert non-empty-string $b */
public static function notEmptyStrOnly(string $b): void
{
if ("" === $b) throw new \Exception("");
}
public function __callStatic() {}
}
/** @return non-empty-string */
function returnNonEmpty(string $b): string
{
ImportedAssert::notEmptyStrOnly($b);
return $b;
}
',
);

$this->analyzeFile('somefile.php', new Context());
}

public function testAssertInvalidDocblockMessageDoesNotIncludeTrace(): void
{
$this->expectException(CodeException::class);
Expand Down

0 comments on commit 8471a89

Please sign in to comment.