Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Dec 23, 2020
1 parent 7b09276 commit 5c9012d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/composer.lock
/tests/tmp/
.phpunit.result.cache
3 changes: 3 additions & 0 deletions src/Extension/ReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ public function enterNode(Node $node): Node
throw new ShouldNotHappenException();
}

// Reset the cache to force a new computation
$node->setAttribute('phpstan_cache_printer', null);

return $scope->getType($node);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/src/Rules/data/throws-php-internal-operators.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ public function test(): void
echo $a / 1;
echo $a / 0; // error: Missing @throws DivisionByZeroError annotation
echo $a / (rand(0, 1) === 0 ? 0 : 1); // error: Missing @throws DivisionByZeroError annotation
echo $a / $b; // error: Missing @throws ArithmeticError annotation
echo $a / $b; // error: Missing @throws DivisionByZeroError annotation
echo (rand(0, 1) === 0 ? 20 : 10) / (rand(0, 1) === 0 ? 5 : 10);

echo $a /= 1;
echo $a /= 0; // error: Missing @throws DivisionByZeroError annotation
echo $a /= (rand(0, 1) === 0 ? 0 : 1); // error: Missing @throws DivisionByZeroError annotation
echo $a /= $b; // error: Missing @throws ArithmeticError annotation
echo $a /= $b; // error: Missing @throws DivisionByZeroError annotation
echo $a /= (rand(0, 1) === 0 ? 5 : 10);

echo $a % 1;
echo $a % 0; // error: Missing @throws DivisionByZeroError annotation
echo $a % (rand(0, 1) === 0 ? 0 : 1); // error: Missing @throws DivisionByZeroError annotation
echo $a % $b; // error: Missing @throws ArithmeticError annotation
echo $a % $b; // error: Missing @throws DivisionByZeroError annotation
echo (rand(0, 1) === 0 ? 20 : 10) % (rand(0, 1) === 0 ? 5 : 10);

echo $a %= 1;
echo $a %= 0; // error: Missing @throws DivisionByZeroError annotation
echo $a %= (rand(0, 1) === 0 ? 0 : 1); // error: Missing @throws DivisionByZeroError annotation
echo $a %= $b; // error: Missing @throws ArithmeticError annotation
echo $a %= $b; // error: Missing @throws DivisionByZeroError annotation
echo $a %= (rand(0, 1) === 0 ? 5 : 10);

echo $a << 0;
Expand Down

0 comments on commit 5c9012d

Please sign in to comment.