From 80aa8594aa4f619c506c8d4b9e2bddada0125473 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 19 Nov 2025 10:11:50 +0100 Subject: [PATCH 1/2] Prevent global side-effect in Bug13813IntegrationTest --- tests/PHPStan/Analyser/Bug13813IntegrationTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/PHPStan/Analyser/Bug13813IntegrationTest.php b/tests/PHPStan/Analyser/Bug13813IntegrationTest.php index 25e937cbed..cf694dd7f4 100644 --- a/tests/PHPStan/Analyser/Bug13813IntegrationTest.php +++ b/tests/PHPStan/Analyser/Bug13813IntegrationTest.php @@ -17,6 +17,8 @@ class Bug13813IntegrationTest extends PHPStanTestCase public function testBug13813(): void { + $oldReporting = error_reporting(); + error_reporting(E_ALL); $analyzerResult = $this->runAnalyse([ __DIR__ . '/data/bug-13813.php', @@ -44,6 +46,8 @@ public function testBug13813(): void $analyzerResult->getAllPhpErrors()[1]->getMessage(), ); } + + error_reporting($oldReporting); } /** From 90257312c396ede520c455f399c413a9d4894d72 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 19 Nov 2025 10:30:38 +0100 Subject: [PATCH 2/2] wrap in try/finally --- .../PHPStan/Analyser/Bug13813IntegrationTest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/PHPStan/Analyser/Bug13813IntegrationTest.php b/tests/PHPStan/Analyser/Bug13813IntegrationTest.php index cf694dd7f4..57fd84cf5a 100644 --- a/tests/PHPStan/Analyser/Bug13813IntegrationTest.php +++ b/tests/PHPStan/Analyser/Bug13813IntegrationTest.php @@ -19,11 +19,15 @@ public function testBug13813(): void { $oldReporting = error_reporting(); - error_reporting(E_ALL); - $analyzerResult = $this->runAnalyse([ - __DIR__ . '/data/bug-13813.php', - __DIR__ . '/Bug13813Rule.php', - ]); + try { + error_reporting(E_ALL); + $analyzerResult = $this->runAnalyse([ + __DIR__ . '/data/bug-13813.php', + __DIR__ . '/Bug13813Rule.php', + ]); + } finally { + error_reporting($oldReporting); + } $this->assertCount(2, $analyzerResult->getAllPhpErrors()); $this->assertCount(2, $analyzerResult->getFilteredPhpErrors()); @@ -46,8 +50,6 @@ public function testBug13813(): void $analyzerResult->getAllPhpErrors()[1]->getMessage(), ); } - - error_reporting($oldReporting); } /**