Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce7182c

Browse files
Update stub file extensions checks
1 parent f961a75 commit ce7182c

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

‎src/Symfony/InputBagStubFilesExtension.php‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,28 @@
22

33
namespace PHPStan\Symfony;
44

5+
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
6+
use PHPStan\BetterReflection\Reflector\Reflector;
57
use PHPStan\PhpDoc\StubFilesExtension;
6-
use function class_exists;
78

89
class InputBagStubFilesExtension implements StubFilesExtension
910
{
1011

12+
/** @var Reflector */
13+
private $reflector;
14+
15+
public function __construct(
16+
Reflector $reflector
17+
)
18+
{
19+
$this->reflector = $reflector;
20+
}
21+
1122
public function getFiles(): array
1223
{
13-
if (!class_exists('Symfony\Component\HttpFoundation\InputBag')) {
24+
try {
25+
$this->reflector->reflectClass('Symfony\Component\HttpFoundation\InputBag');
26+
} catch (IdentifierNotFound $e) {
1427
return [];
1528
}
1629

‎src/Symfony/PasswordAuthenticatedUserStubFilesExtension.php‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,28 @@
22

33
namespace PHPStan\Symfony;
44

5+
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
6+
use PHPStan\BetterReflection\Reflector\Reflector;
57
use PHPStan\PhpDoc\StubFilesExtension;
6-
use function interface_exists;
78

89
class PasswordAuthenticatedUserStubFilesExtension implements StubFilesExtension
910
{
1011

12+
/** @var Reflector */
13+
private $reflector;
14+
15+
public function __construct(
16+
Reflector $reflector
17+
)
18+
{
19+
$this->reflector = $reflector;
20+
}
21+
1122
public function getFiles(): array
1223
{
13-
if (!interface_exists('Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface')) {
24+
try {
25+
$this->reflector->reflectClass('Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface');
26+
} catch (IdentifierNotFound $e) {
1427
return [];
1528
}
1629

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /