-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix static reflection issues with custom autoloaders
- Loading branch information
1 parent
50cbc45
commit 6962280
Showing
5 changed files
with
69 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
src/Reflection/BetterReflection/SourceLocator/AutoloadFunctionsSourceLocator.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,34 @@ | ||
<?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 PHPStan\autoloadFunctions; | ||
|
||
class AutoloadFunctionsSourceLocator implements SourceLocator | ||
{ | ||
|
||
public function locateIdentifier(Reflector $reflector, Identifier $identifier): ?Reflection | ||
{ | ||
if (!$identifier->isClass()) { | ||
return null; | ||
} | ||
|
||
$autoloadFunctions = autoloadFunctions(); | ||
foreach ($autoloadFunctions as $autoloadFunction) { | ||
$autoloadFunction($identifier->getName()); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array | ||
{ | ||
return []; | ||
} | ||
|
||
} |
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,11 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan; | ||
|
||
/** | ||
* @return array<int, callable(string): void> | ||
*/ | ||
function autoloadFunctions(): array // phpcs:ignore Squiz.Functions.GlobalFunction.Found | ||
{ | ||
return $GLOBALS['__phpstanAutoloadFunctions'] ?? []; | ||
} |