Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58b6023
commit 46f51e7
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Reflection/BetterReflection/SourceLocator/RectorAutoloadSourceLocator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\BetterReflection\SourceLocator; | ||
|
||
use PHPStan\BetterReflection\Identifier\Identifier; | ||
use PHPStan\BetterReflection\Identifier\IdentifierType; | ||
use PHPStan\BetterReflection\Reflection\Reflection; | ||
use PHPStan\BetterReflection\Reflector\Reflector; | ||
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator; | ||
use function class_exists; | ||
use function interface_exists; | ||
use function strpos; | ||
use function strtolower; | ||
use function trait_exists; | ||
|
||
class RectorAutoloadSourceLocator implements SourceLocator | ||
{ | ||
|
||
public function locateIdentifier(Reflector $reflector, Identifier $identifier): ?Reflection | ||
{ | ||
if (!$identifier->isClass()) { | ||
return null; | ||
} | ||
|
||
$className = strtolower($identifier->getName()); | ||
if (strpos($className, 'rectorprefix') === 0 || strpos($className, 'rector\\') === 0) { | ||
class_exists($identifier->getName()) || interface_exists($identifier->getName()) || trait_exists($identifier->getName()); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array | ||
{ | ||
return []; | ||
} | ||
|
||
} |