-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Use composer.json reading just to locate functions"
This reverts commit 4cbb589.
- Loading branch information
1 parent
1c63a78
commit 37356d4
Showing
5 changed files
with
196 additions
and
9 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
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
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
54 changes: 54 additions & 0 deletions
54
src/Reflection/BetterReflection/SourceLocator/OptimizedPsrAutoloaderLocator.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,54 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\BetterReflection\SourceLocator; | ||
|
||
use Roave\BetterReflection\Identifier\Identifier; | ||
use Roave\BetterReflection\Identifier\IdentifierType; | ||
use Roave\BetterReflection\Reflection\Reflection; | ||
use Roave\BetterReflection\Reflector\Reflector; | ||
use Roave\BetterReflection\SourceLocator\Type\Composer\Psr\PsrAutoloaderMapping; | ||
use Roave\BetterReflection\SourceLocator\Type\SourceLocator; | ||
|
||
class OptimizedPsrAutoloaderLocator implements SourceLocator | ||
{ | ||
|
||
private PsrAutoloaderMapping $mapping; | ||
|
||
private \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository; | ||
|
||
public function __construct( | ||
PsrAutoloaderMapping $mapping, | ||
OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository | ||
) | ||
{ | ||
$this->mapping = $mapping; | ||
$this->optimizedSingleFileSourceLocatorRepository = $optimizedSingleFileSourceLocatorRepository; | ||
} | ||
|
||
public function locateIdentifier(Reflector $reflector, Identifier $identifier): ?Reflection | ||
{ | ||
foreach ($this->mapping->resolvePossibleFilePaths($identifier) as $file) { | ||
if (!file_exists($file)) { | ||
continue; | ||
} | ||
|
||
$reflection = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($file)->locateIdentifier($reflector, $identifier); | ||
if ($reflection === null) { | ||
continue; | ||
} | ||
|
||
return $reflection; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* @return Reflection[] | ||
*/ | ||
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array | ||
{ | ||
return []; // todo | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/Reflection/BetterReflection/SourceLocator/OptimizedPsrAutoloaderLocatorFactory.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,12 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\BetterReflection\SourceLocator; | ||
|
||
use Roave\BetterReflection\SourceLocator\Type\Composer\Psr\PsrAutoloaderMapping; | ||
|
||
interface OptimizedPsrAutoloaderLocatorFactory | ||
{ | ||
|
||
public function create(PsrAutoloaderMapping $mapping): OptimizedPsrAutoloaderLocator; | ||
|
||
} |