Skip to content

Commit 37c48d7

Browse files
authored
Standarize reflection usage (#424)
1 parent 2034312 commit 37c48d7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

dev-tools/src/Readme/ReadmeCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ private function fixers(): string
173173

174174
/** @var AbstractFixer $fixer */
175175
foreach (new Fixers() as $fixer) {
176-
$reflection = new \ReflectionClass($fixer);
176+
$reflectionClass = new \ReflectionClass($fixer);
177177

178178
$output .= \sprintf(
179179
"\n#### %s\n%s",
180-
$reflection->getShortName(),
180+
$reflectionClass->getShortName(),
181181
$fixer->getDefinition()->getSummary()
182182
);
183183

tests/AutoReview/SrcCodeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testFixerHasValidName(FixerInterface $fixer): void
5858
*/
5959
public function testFixerIsFinal(FixerInterface $fixer): void
6060
{
61-
self::assertTrue((new \ReflectionClass($fixer))->isFinal());
61+
self::assertTrue((new \ReflectionObject($fixer))->isFinal());
6262
}
6363

6464
/**
@@ -74,7 +74,7 @@ public function testFixerIsNotBothDeprecatingAndDeprecated(FixerInterface $fixer
7474
*/
7575
public function testDeprecatedFixerHasAnnotation(FixerInterface $fixer): void
7676
{
77-
$comment = (new \ReflectionClass($fixer))->getDocComment();
77+
$comment = (new \ReflectionObject($fixer))->getDocComment();
7878
self::assertSame(
7979
$fixer instanceof DeprecatedFixerInterface,
8080
\strpos($comment === false ? '' : $comment, '@deprecated') !== false
@@ -103,8 +103,8 @@ public function testFixerSupportsAllFilesByDefault(): void
103103
*/
104104
public function testThereIsNoPregFunctionUsedDirectly(string $className): void
105105
{
106-
$rc = new \ReflectionClass($className);
107-
$tokens = Tokens::fromCode(\file_get_contents($rc->getFileName()));
106+
$reflectionClass = new \ReflectionClass($className);
107+
$tokens = Tokens::fromCode(\file_get_contents($reflectionClass->getFileName()));
108108
$stringTokens = \array_filter(
109109
$tokens->toArray(),
110110
static function (Token $token): bool {

tests/AutoReview/TestsCodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ public static function provideDataProviderCases(): iterable
9595
*/
9696
private static function getDataProviderMethodNames(string $className): array
9797
{
98-
$reflection = new \ReflectionClass($className);
98+
$reflectionClass = new \ReflectionClass($className);
9999

100100
$dataProviderMethodNames = [];
101101

102-
foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
102+
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
103103
$docBlock = new DocBlock($method->getDocComment());
104104
$dataProviderAnnotations = $docBlock->getAnnotationsOfType('dataProvider');
105105

tests/Fixer/SingleSpaceAfterStatementFixerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ public function testTokenIsUseful(int $token): void
289289
$expectedTokens = Tokens::fromCode(self::EXAMPLE_WITH_ALL_TOKENS);
290290
$this->fixer->fix($this->createMock(\SplFileInfo::class), $expectedTokens);
291291

292-
$reflection = new \ReflectionClass($this->fixer);
293-
$property = $reflection->getProperty('tokens');
292+
$reflectionObject = new \ReflectionObject($this->fixer);
293+
$property = $reflectionObject->getProperty('tokens');
294294
$property->setAccessible(true);
295295
$property->setValue($this->fixer, \array_diff($property->getValue($this->fixer), [$token]));
296296

@@ -307,8 +307,8 @@ public function testTokenIsUseful(int $token): void
307307
public static function provideTokenIsUsefulCases(): iterable
308308
{
309309
$fixer = new SingleSpaceAfterStatementFixer();
310-
$reflection = new \ReflectionClass($fixer);
311-
$property = $reflection->getProperty('tokens');
310+
$reflectionObject = new \ReflectionObject($fixer);
311+
$property = $reflectionObject->getProperty('tokens');
312312
$property->setAccessible(true);
313313

314314
foreach ($property->getValue($fixer) as $token) {

0 commit comments

Comments
 (0)