From 5c9012d0717d1beea32309abd404478ae384916c Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 24 Dec 2020 00:30:58 +0100 Subject: [PATCH] Fix tests --- .gitignore | 1 + src/Extension/ReflectionExtension.php | 3 +++ tests/src/Rules/data/throws-php-internal-operators.php | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a04d2e1..c125daf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor/ /composer.lock /tests/tmp/ +.phpunit.result.cache diff --git a/src/Extension/ReflectionExtension.php b/src/Extension/ReflectionExtension.php index f2967ae..3d78759 100644 --- a/src/Extension/ReflectionExtension.php +++ b/src/Extension/ReflectionExtension.php @@ -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); } diff --git a/tests/src/Rules/data/throws-php-internal-operators.php b/tests/src/Rules/data/throws-php-internal-operators.php index 4642414..c564e20 100644 --- a/tests/src/Rules/data/throws-php-internal-operators.php +++ b/tests/src/Rules/data/throws-php-internal-operators.php @@ -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;