Skip to content

Commit

Permalink
Fix UnusedClosureUsesRule for already traversed match
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 21, 2023
1 parent 5b7bb23 commit a719486
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ jobs:
extensions: ""
- script: "bin/phpstan analyse -l 8 tests/e2e/anon-class/Granularity.php"
extensions: ""
- script: "bin/phpstan analyse -l 8 e2e/phpstan-phpunit-190/test.php -c e2e/phpstan-phpunit-190/test.neon"
extensions: ""

steps:
- name: "Checkout"
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions e2e/phpstan-phpunit-190/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php // lint >= 8.1

namespace PhpstanPhpUnit190;

class FoobarTest
{
public function testBaz(): int
{
$matcher = new self();
$this->acceptCallback(static function (string $test) use ($matcher): string {
match ($matcher->testBaz()) {
1 => 1,
2 => 2,
default => new \LogicException()
};

return $test;
});

return 1;
}

public function acceptCallback(callable $cb): void
{

}
}
4 changes: 2 additions & 2 deletions src/Node/Expr/AlwaysRememberedExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class AlwaysRememberedExpr extends Expr implements VirtualNode
{

public function __construct(private Expr $expr, private Type $type, private Type $nativeType)
public function __construct(public Expr $expr, private Type $type, private Type $nativeType)
{
parent::__construct([]);
}
Expand Down Expand Up @@ -39,7 +39,7 @@ public function getType(): string
*/
public function getSubNodeNames(): array
{
return [];
return ['expr'];
}

}

0 comments on commit a719486

Please sign in to comment.