Skip to content

Commit 67fe930

Browse files
committed
Make runtime reflection instantiation test independent of InstantiationRule's PHP-version-specific errors
Amp-Thread-ID: https://ampcode.com/threads/T-01a1bf5f-ca34-7733-8886-c850b9908584
1 parent 0c923a2 commit 67fe930

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎tests/PHPStan/Rules/Api/RuntimeReflectionInstantiationUsageExtensionTest.php‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,23 @@ public function testRule(): void
7373
'Creating new ReflectionEnum is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
7474
56,
7575
];
76-
$errors[] = [
77-
'Parameter #1 $objectOrClass of class ReflectionEnum constructor expects class-string<T of UnitEnum>|T of UnitEnum, string given.',
78-
56,
79-
];
8076
$errors[] = [
8177
'Creating new ReflectionEnumBackedCase is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
8278
57,
8379
];
8480
}
85-
$this->analyse([__DIR__ . '/data/runtime-reflection-instantiation.php'], $errors);
81+
82+
// InstantiationRule's own errors on this file differ between PHP versions
83+
$actualErrors = [];
84+
foreach ($this->gatherAnalyserErrors([__DIR__ . '/data/runtime-reflection-instantiation.php']) as $error) {
85+
if ($error->getIdentifier() !== 'phpstanApi.runtimeReflection') {
86+
continue;
87+
}
88+
89+
$actualErrors[] = [$error->getMessage(), $error->getLine()];
90+
}
91+
92+
$this->assertSame($errors, $actualErrors);
8693
}
8794

8895
}

0 commit comments

Comments
 (0)