Skip to content

Commit 912e769

Browse files
xificurkstaabm
andauthored
Remove Reflector from StubFilesExtensionLoader, replace with version checks (#486)
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
1 parent 809c1e6 commit 912e769

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

src/Stubs/Symfony/StubFilesExtensionLoader.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use Composer\InstalledVersions;
66
use OutOfBoundsException;
7-
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
8-
use PHPStan\BetterReflection\Reflector\Reflector;
97
use PHPStan\PhpDoc\StubFilesExtension;
108
use function class_exists;
119
use function dirname;
@@ -14,18 +12,9 @@
1412
class StubFilesExtensionLoader implements StubFilesExtension
1513
{
1614

17-
private Reflector $reflector;
18-
19-
public function __construct(
20-
Reflector $reflector
21-
)
22-
{
23-
$this->reflector = $reflector;
24-
}
25-
2615
public function getFiles(): array
2716
{
28-
$stubsDir = dirname(dirname(dirname(__DIR__))) . '/stubs';
17+
$stubsDir = dirname(__DIR__, 3) . '/stubs';
2918
$files = [];
3019

3120
if ($this->isInstalledVersionBelow('symfony/security-bundle', '6.3.0.0')) {
@@ -82,12 +71,9 @@ public function getFiles(): array
8271
if ($this->isInstalledVersionBelow('symfony/http-foundation', '7.4.0.0')) {
8372
$files[] = $stubsDir . '/Symfony/Component/HttpFoundation/ParameterBag.stub';
8473

85-
try {
86-
$this->reflector->reflectClass('Symfony\Component\HttpFoundation\InputBag');
74+
if (!$this->isInstalledVersionBelow('symfony/http-foundation', '5.1.0.0')) {
8775
$files[] = $stubsDir . '/Symfony/Component/HttpFoundation/InputBag.stub';
8876
$files[] = $stubsDir . '/Symfony/Component/HttpFoundation/Request.stub';
89-
} catch (IdentifierNotFound $e) {
90-
// Don't load the InputBag and the associated Request stubs for older Symfony versions that did not have InputBag yet to avoid breaking the Request.
9177
}
9278
}
9379

0 commit comments

Comments
 (0)