Skip to content

Commit

Permalink
Always use getKeepVoidType
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed May 14, 2024
1 parent d3a6576 commit 1a148c0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
5 changes: 0 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ parameters:
message: "#but it's missing from the PHPDoc @throws tag\\.$#" # allow uncatched exceptions in tests
path: tests/*

-
message: '#^Call to function method_exists\(\) with PHPStan\\Analyser\\Scope and ''getKeepVoidType'' will always evaluate to true\.$#'
path: src/Rule/ForbidUnusedMatchResultRule.php
reportUnmatched: false # fails only for PHPStan > 1.10.49

# ignore BC promises
- identifier: phpstanApi.class
- identifier: phpstanApi.method
Expand Down
5 changes: 1 addition & 4 deletions src/Rule/ForbidUnusedMatchResultRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public function processNode(Node $node, Scope $scope): array
$returnedTypes = [];

foreach ($node->arms as $arm) {
/** @var Type $armType */
$armType = method_exists($scope, 'getKeepVoidType') // Needed since https://github.com/phpstan/phpstan/releases/tag/1.10.49, can be dropped once we bump PHPStan version gte that
? $scope->getKeepVoidType($arm->body)
: $scope->getType($arm->body);
$armType = $scope->getKeepVoidType($arm->body);

if (!$armType->isVoid()->yes() && !$armType instanceof NeverType && !$arm->body instanceof Assign) {
$returnedTypes[] = $armType;
Expand Down

0 comments on commit 1a148c0

Please sign in to comment.