Skip to content

Commit 2618882

Browse files
ondrejmirtesclaude
andcommitted
Revert "Run bootstrap-registered autoloaders inside the file-read trap (#6185)"
This reverts commit 8e2efc0, keeping the bug-14988 e2e test. Its workflow step is commented out - without the reverted fix, a bootstrap autoloader re-includes an already loaded file and the child process dies with a redeclare fatal again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS
1 parent 8cb564a commit 2618882

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ jobs:
128128
cd e2e/bug-14514
129129
composer install
130130
../../bin/phpstan analyze bug-14515.php
131-
- script: |
132-
cd e2e/bug-14988
133-
composer install
134-
../../bin/phpstan analyse
135131
# Fails since the revert of the bootstrap autoloader changes:
136132
# - script: |
133+
# cd e2e/bug-14988
134+
# composer install
135+
# ../../bin/phpstan analyse
136+
# - script: |
137137
# cd e2e/bug-12972b
138138
# composer install
139139
# ../../bin/phpstan analyze

src/Reflection/BetterReflection/SourceLocator/AutoloadFunctionsSourceLocator.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use PHPStan\BetterReflection\Reflector\Reflector;
1010
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
1111
use function class_exists;
12-
use function function_exists;
1312
use function interface_exists;
1413
use function PHPStan\autoloadFunctions;
1514
use function trait_exists;
@@ -36,18 +35,6 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
3635
return null;
3736
}
3837

39-
// If the name is already a defined function, this locator must not run the bootstrap
40-
// autoloaders for it: a catch-all autoloader (e.g. PHP_CodeSniffer's, which falls back to
41-
// Composer's findFile()) would resolve the name to the function's own file and plain-include
42-
// it a second time - it was loaded once already, e.g. by a package that ships one function
43-
// per PSR-4 path and requires it from its bootstrap - fatally redeclaring the function.
44-
// Returning null only declines this locator; a class and a function may share a name in PHP,
45-
// and a class that genuinely exists under this name in another file is still located by the
46-
// later source locators in the chain. See https://github.com/phpstan/phpstan/issues/14988
47-
if (function_exists($className)) {
48-
return null;
49-
}
50-
5138
$autoloadFunctions = autoloadFunctions();
5239
foreach ($autoloadFunctions as $autoloadFunction) {
5340
$autoloadFunction($className);

0 commit comments

Comments
 (0)