diff --git a/src/Analyser/StmtHandler/DeclareHandler.php b/src/Analyser/StmtHandler/DeclareHandler.php index 25518f529e8..b9fba510f09 100644 --- a/src/Analyser/StmtHandler/DeclareHandler.php +++ b/src/Analyser/StmtHandler/DeclareHandler.php @@ -44,6 +44,7 @@ public function processStmt( $impurePoints = []; $alwaysTerminating = false; $exitPoints = []; + $variableFlow = null; foreach ($stmt->declares as $declare) { $nodeScopeResolver->callNodeCallback($nodeCallback, $declare, $scope, $storage); // the value is a constant scalar - process it so its result is stored @@ -69,9 +70,10 @@ public function processStmt( $impurePoints = $result->getImpurePoints(); $alwaysTerminating = $result->isAlwaysTerminating(); $exitPoints = $result->getExitPoints(); + $variableFlow = $result->getVariableFlow(); } - return new InternalStatementResult($scope, hasYield: $hasYield, isAlwaysTerminating: $alwaysTerminating, exitPoints: $exitPoints, throwPoints: $throwPoints, impurePoints: $impurePoints, dependencies: Dependencies::merge(...$dependencies)); + return new InternalStatementResult($scope, hasYield: $hasYield, isAlwaysTerminating: $alwaysTerminating, exitPoints: $exitPoints, throwPoints: $throwPoints, impurePoints: $impurePoints, variableFlow: $variableFlow, dependencies: Dependencies::merge(...$dependencies)); } } diff --git a/src/Turbo/TurboExtensionEnabler.php b/src/Turbo/TurboExtensionEnabler.php index 25e6990b99e..6b2c2df1665 100644 --- a/src/Turbo/TurboExtensionEnabler.php +++ b/src/Turbo/TurboExtensionEnabler.php @@ -33,7 +33,7 @@ final class TurboExtensionEnabler { - public const EXPECTED_EXTENSION_VERSION = '55df31e'; + public const EXPECTED_EXTENSION_VERSION = '4463d60'; private static bool $active = false; diff --git a/tests/PHPStan/Rules/DeadCode/UnusedVariableRuleTest.php b/tests/PHPStan/Rules/DeadCode/UnusedVariableRuleTest.php index 2ceca6991c7..78481967d17 100644 --- a/tests/PHPStan/Rules/DeadCode/UnusedVariableRuleTest.php +++ b/tests/PHPStan/Rules/DeadCode/UnusedVariableRuleTest.php @@ -23,6 +23,14 @@ public function testBug15411(): void $this->analyse([__DIR__ . '/data/bug-15411.php'], []); } + public function testBug15394(): void + { + $this->analyse([__DIR__ . '/data/bug-15394.php'], [ + ['Variable $unused is never read.', 34], + ['Value assigned to variable $value is never read before being overwritten.', 40], + ]); + } + public function testThrowableCatchAfterDocumentedException(): void { $this->analyse([__DIR__ . '/data/unused-variable-throwable-catch.php'], []); diff --git a/tests/PHPStan/Rules/DeadCode/data/bug-15394.php b/tests/PHPStan/Rules/DeadCode/data/bug-15394.php new file mode 100644 index 00000000000..236b477733b --- /dev/null +++ b/tests/PHPStan/Rules/DeadCode/data/bug-15394.php @@ -0,0 +1,60 @@ +