diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index dbd1418a1d..d7ed5cc81b 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -2398,8 +2398,10 @@ static function (): void { && $functionReflection->getName() === 'file_put_contents' && count($expr->getArgs()) > 0 ) { - $scope = $scope->invalidateExpression(new FuncCall(new Name('file_get_contents'), [$expr->getArgs()[0]])) - ->invalidateExpression(new FuncCall(new Name\FullyQualified('file_get_contents'), [$expr->getArgs()[0]])); + foreach (['file_get_contents', 'filesize'] as $functionToInvalidate) { + $scope = $scope->invalidateExpression(new FuncCall(new Name($functionToInvalidate), [$expr->getArgs()[0]])) + ->invalidateExpression(new FuncCall(new Name\FullyQualified($functionToInvalidate), [$expr->getArgs()[0]])); + } } if ( diff --git a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php index ae47818512..bc3421a5e8 100644 --- a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php @@ -231,4 +231,9 @@ public function testBug6467(): void $this->analyse([__DIR__ . '/data/bug-6467.php'], []); } + public function testBug11484(): void + { + $this->analyse([__DIR__ . '/data/bug-11484.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Comparison/data/bug-11484.php b/tests/PHPStan/Rules/Comparison/data/bug-11484.php new file mode 100644 index 0000000000..19891e80e1 --- /dev/null +++ b/tests/PHPStan/Rules/Comparison/data/bug-11484.php @@ -0,0 +1,17 @@ + 100) { + file_put_contents("file.txt", str_repeat('aaaaaaa', rand(1,100))); + if (filesize("file.txt") > 50) { + + } + } + + } +}