Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vimeo/psalm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.23.0
Choose a base ref
...
head repository: vimeo/psalm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.23.1
Choose a head ref
  • 3 commits
  • 2 files changed
  • 3 contributors

Commits on Mar 11, 2024

  1. Added test for #10807

    SCIF authored and weirdan committed Mar 11, 2024
    Copy the full SHA
    2a91bd6 View commit details
  2. Resolve fail test #10807

    Resolved problem:
    ```
    Psalm\Tests\AssertAnnotationTest::testAssertsAllongCallStaticMethodWork
    Psalm\Exception\CodeException: LessSpecificReturnStatement
    The type 'string' is more general than the declared return type 'non-empty-string' for returnNonEmpty
    ```
    issidorov authored and weirdan committed Mar 11, 2024
    Copy the full SHA
    fe42e88 View commit details
  3. Merge pull request #10812 from issidorov/bug-10807

    weirdan authored Mar 11, 2024
    Copy the full SHA
    8471a89 View commit details
Showing with 31 additions and 1 deletion.
  1. +1 −1 src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
  2. +30 −0 tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
@@ -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,
30 changes: 30 additions & 0 deletions tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
@@ -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);