Skip to content

Commit 5f69f0f

Browse files
NickSdotnicolas-grekas
authored andcommitted
[Form][PhpUnitBridge] Remove usage of noop ReflectionProperty::setAccessible()
1 parent da8bc22 commit 5f69f0f

File tree

8 files changed

+0
-13
lines changed

8 files changed

+0
-13
lines changed

src/Symfony/Bridge/PhpUnit/CoverageListener.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function startTest(Test $test): void
8686
private function addCoversForClassToAnnotationCache(Test $test, array $covers): void
8787
{
8888
$r = new \ReflectionProperty(TestUtil::class, 'annotationCache');
89-
$r->setAccessible(true);
9089

9190
$cache = $r->getValue();
9291
$cache = array_replace_recursive($cache, [
@@ -103,7 +102,6 @@ private function addCoversForDocBlockInsideRegistry(Test $test, array $covers):
103102
$docBlock = Registry::getInstance()->forClassName(\get_class($test));
104103

105104
$symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations');
106-
$symbolAnnotations->setAccessible(true);
107105

108106
// Exclude internal classes; PHPUnit 9.1+ is picky about tests covering, say, a \RuntimeException
109107
$covers = array_filter($covers, function (string $class) {

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ public function toString()
437437
{
438438
$exception = new \Exception($this->message);
439439
$reflection = new \ReflectionProperty($exception, 'trace');
440-
$reflection->setAccessible(true);
441440
$reflection->setValue($exception, $this->trace);
442441

443442
return ($this->originatesFromAnObject() ? 'deprecation triggered by '.$this->originatingClass().'::'.$this->originatingMethod().":\n" : '')

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ private function willBeIsolated(TestCase $test): bool
357357
}
358358

359359
$r = new \ReflectionProperty($test, 'runTestInSeparateProcess');
360-
$r->setAccessible(true);
361360

362361
return $r->getValue($test) ?? false;
363362
}

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ public static function setUpBeforeClass(): void
275275
$loader = require $v.'/autoload.php';
276276
$reflection = new \ReflectionClass($loader);
277277
$prop = $reflection->getProperty('prefixDirsPsr4');
278-
$prop->setAccessible(true);
279278
$currentValue = $prop->getValue($loader);
280279
self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue];
281280
$currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ public function testGetEnvDoesNotAutoCastNullWithDefaultEnvVarProcessor()
420420
$container->compile();
421421

422422
$r = new \ReflectionMethod($container, 'getEnv');
423-
$r->setAccessible(true);
424423
$this->assertNull($r->invoke($container, 'FOO'));
425424
}
426425

@@ -436,7 +435,6 @@ public function testGetEnvDoesNotAutoCastNullWithEnvVarProcessorsLocatorReturnin
436435
$container->compile();
437436

438437
$r = new \ReflectionMethod($container, 'getEnv');
439-
$r->setAccessible(true);
440438
$this->assertNull($r->invoke($container, 'FOO'));
441439
}
442440
}

src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class ErrorHandlerTest extends TestCase
3434
protected function tearDown(): void
3535
{
3636
$r = new \ReflectionProperty(ErrorHandler::class, 'exitCode');
37-
$r->setAccessible(true);
3837
$r->setValue(null, 0);
3938
}
4039

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ public function testRoundMethodKeepsIntegersAsIntegers()
754754
// Use reflection to test the private round() method directly
755755
$reflection = new \ReflectionClass($transformer);
756756
$roundMethod = $reflection->getMethod('round');
757-
$roundMethod->setAccessible(true);
758757

759758
$int = \PHP_INT_MAX - 1;
760759
$result = $roundMethod->invoke($transformer, $int);

src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public function testThrowsTransportExceptionOnFailure()
9494
$sendmailTransport->send($mail, $envelope);
9595

9696
$streamProperty = new \ReflectionProperty(SendmailTransport::class, 'stream');
97-
$streamProperty->setAccessible(true);
9897
$stream = $streamProperty->getValue($sendmailTransport);
9998
$this->assertNull($stream->stream);
10099
}
@@ -112,10 +111,8 @@ public function testStreamIsClearedOnFailure()
112111
}
113112

114113
$streamProperty = new \ReflectionProperty(SendmailTransport::class, 'stream');
115-
$streamProperty->setAccessible(true);
116114
$stream = $streamProperty->getValue($sendmailTransport);
117115
$innerStreamProperty = new \ReflectionProperty(ProcessStream::class, 'stream');
118-
$innerStreamProperty->setAccessible(true);
119116
$this->assertNull($innerStreamProperty->getValue($stream));
120117
}
121118

@@ -127,7 +124,6 @@ public function testDoesNotThrowWhenInteractive()
127124

128125
$sendmailTransport = new SendmailTransport(self::FAKE_INTERACTIVE_SENDMAIL);
129126
$transportProperty = new \ReflectionProperty(SendmailTransport::class, 'transport');
130-
$transportProperty->setAccessible(true);
131127

132128
// Replace the transport with an anonymous consumer that trigger the stream methods
133129
$transportProperty->setValue($sendmailTransport, new class($transportProperty->getValue($sendmailTransport)->getStream()) extends SmtpTransport {

0 commit comments

Comments
 (0)