From 85760a17fa7895e8f6cc3c70cddcd21af5350844 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 5 May 2024 09:14:07 +0200 Subject: [PATCH] Remove obsolete code (setAccessible(true)) --- src/Test/IntegrationTestCase.php | 1 - tests/Node/Expression/CallTest.php | 1 - tests/ParserTest.php | 6 ------ tests/Profiler/Dumper/AbstractTest.php | 4 ---- 4 files changed, 12 deletions(-) diff --git a/src/Test/IntegrationTestCase.php b/src/Test/IntegrationTestCase.php index f3ee733866..ac81cfb4ee 100644 --- a/src/Test/IntegrationTestCase.php +++ b/src/Test/IntegrationTestCase.php @@ -188,7 +188,6 @@ protected function doIntegrationTest($file, $message, $condition, $templates, $e // avoid using the same PHP class name for different cases $p = new \ReflectionProperty($twig, 'templateClassPrefix'); - $p->setAccessible(true); $p->setValue($twig, '__TwigTemplate_'.hash('xxh128', uniqid((string) mt_rand(), true), false).'_'); $deprecations = []; diff --git a/tests/Node/Expression/CallTest.php b/tests/Node/Expression/CallTest.php index 72681a4a1f..72a04f9600 100644 --- a/tests/Node/Expression/CallTest.php +++ b/tests/Node/Expression/CallTest.php @@ -100,7 +100,6 @@ public function customFunction($arg1, $arg2 = 'default', $arg3 = []) private function getArguments($call, $args) { $m = new \ReflectionMethod($call, 'getArguments'); - $m->setAccessible(true); return $m->invokeArgs($call, $args); } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index cdd8e87574..d4a5f0c299 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -63,8 +63,6 @@ public function testFilterBodyNodes($input, $expected) { $parser = $this->getParser(); $m = new \ReflectionMethod($parser, 'filterBodyNodes'); - $m->setAccessible(true); - $this->assertEquals($expected, $m->invoke($parser, $input)); } @@ -96,8 +94,6 @@ public function testFilterBodyNodesThrowsException($input) $parser = $this->getParser(); $m = new \ReflectionMethod($parser, 'filterBodyNodes'); - $m->setAccessible(true); - $m->invoke($parser, $input); } @@ -117,7 +113,6 @@ public function testFilterBodyNodesWithBOM($emptyNode) $parser = $this->getParser(); $m = new \ReflectionMethod($parser, 'filterBodyNodes'); - $m->setAccessible(true); $this->assertNull($m->invoke($parser, new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$emptyNode, 1))); } @@ -181,7 +176,6 @@ protected function getParser() $parser->setParent(new Node()); $p = new \ReflectionProperty($parser, 'stream'); - $p->setAccessible(true); $p->setValue($parser, new TokenStream([])); return $parser; diff --git a/tests/Profiler/Dumper/AbstractTest.php b/tests/Profiler/Dumper/AbstractTest.php index 1891c27507..6b7acb1a9b 100644 --- a/tests/Profiler/Dumper/AbstractTest.php +++ b/tests/Profiler/Dumper/AbstractTest.php @@ -39,7 +39,6 @@ protected function getProfile() ]; $p = new \ReflectionProperty($profile, 'profiles'); - $p->setAccessible(true); $p->setValue($profile, $subProfiles); return $profile; @@ -83,18 +82,15 @@ private function generateProfile($name, $duration, $type, $templateName, array $ $profile = new Profile($templateName, $type, $name); $p = new \ReflectionProperty($profile, 'profiles'); - $p->setAccessible(true); $p->setValue($profile, $subProfiles); $starts = new \ReflectionProperty($profile, 'starts'); - $starts->setAccessible(true); $starts->setValue($profile, [ 'wt' => 0, 'mu' => 0, 'pmu' => 0, ]); $ends = new \ReflectionProperty($profile, 'ends'); - $ends->setAccessible(true); $ends->setValue($profile, [ 'wt' => $duration, 'mu' => 0,