Revert the bootstrap autoloader execution changes - #6292
Conversation
…k for, running them for real only when that cannot redeclare a symbol" This reverts commit 598faaa, keeping the bug-15102c e2e test and its workflow entry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS
This reverts commit c10897b, keeping the bug-15102 e2e test and its workflow entry. It also reverts 9680cc4 (Use early exit when collecting the registered class loaders), which only restyled the code being reverted here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS
…a loaded file" This reverts commit 7fde888. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS
…e static source locators (#6069)" This reverts commit f896750, keeping the bug-12972b and bug-12972c e2e tests. The bug-12972b workflow step is commented out - without the reverted fix, the eagerly-run bootstrap autoloader's own guard exception aborts the analysis again. BootstrapFilesRunner::mergeNewAutoloadFunctions() - extracted from CommandHelper::begin() when bootstrapFiles started running per forked worker - goes back to the inline pre-revert collection: every newly registered autoloader is appended to $GLOBALS['__phpstanAutoloadFunctions'], with no prepended/appended split around the project's class loader. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS
#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
c470f27 to
2618882
Compare
|
/cc @SanderMuller @staabm This will reopen phpstan/phpstan#14976 and phpstan/phpstan#14988 but otherwise everything broken after #6069 and #6185 keeps working. Besides reported issues in phpstan/phpstan#15102 (from which we are keeping the E2E tests) the fix attempts also broke various popular class loaders like in TYPO3, Larastan and also RobotLoader. As I said somewhere else, every intervention in BetterReflectionSourceLocatorFactory will fix one use case but break another, it's inevitable as the current ordering definitely works for some unknown percentage of PHPStan users. To me it's important not to break PHPStan working for people out there. Of course you're welcome to try solving phpstan/phpstan#14976 and phpstan/phpstan#14988 in the future, but it won't be easy. Thank you for understanding. |
|
Understood, and agreed on the constraint - a fix that trades one working setup for another is not a fix. Starting from the other end then: #6293 adds e2e coverage for the two loader shapes that broke, using the real packages, so a future attempt at #14976/#14988 has a gate instead of waiting for user reports. Test-only,
The RobotLoader one is the shape I wish had existed before any of this: on With those in place the gate for a retry is explicit: turn Also: I corrected phpstan/phpstan#15118 - baseline is empty now (the five |
phpstan#6292 reverted five commits because the attempts fixed one use case and broke another, and only some of those breakages had an e2e project. These two do not test PHPStan's current behaviour so much as pin the shapes a future attempt at phpstan/phpstan#14976 and phpstan/phpstan#14988 must not regress. class-alias-loader uses the real typo3/class-alias-loader: it replaces Composer's loader with its own wrapper, resolves a legacy name through a class alias map, and an IDE-only stub in the analysed paths declares that name as a plain class. The alias has to win. 2.2.9 returns the stub and reports a missing method. robot-loader registers a Nette RobotLoader over a directory Composer does not map, so only that loader can find the class. RobotLoader locks and writes a cache file while resolving, which fails inside the file-read trap: on 598faaa the analysis dies in RobotLoader::acquireLock() with "Unable to create file '<tmp>/....php.lock'". Both pass on this commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#6292 reverted five commits because the attempts fixed one use case and broke another, and only some of those breakages had an e2e project. These two do not test PHPStan's current behaviour so much as pin the shapes a future attempt at phpstan/phpstan#14976 and phpstan/phpstan#14988 must not regress. class-alias-loader uses the real typo3/class-alias-loader: it replaces Composer's loader with its own wrapper, resolves a legacy name through a class alias map, and an IDE-only stub in the analysed paths declares that name as a plain class. The alias has to win. 2.2.9 returns the stub and reports a missing method. robot-loader registers a Nette RobotLoader over a directory Composer does not map, so only that loader can find the class. RobotLoader locks and writes a cache file while resolving, which fails inside the file-read trap: on 598faaa the analysis dies in RobotLoader::acquireLock() with "Unable to create file '<tmp>/....php.lock'". Both pass on this commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reverts the five bootstrap-autoloader commits, keeping every e2e test they added so the repo keeps documenting which shapes regress:
The touched files are back to their 2.2.8 state, except
bin/phpstan(keeps theTurboProcessRestarterlines) and the bootstrapFiles flow: the collection loop that used to live inline inCommandHelper::begin()now lives inBootstrapFilesRunner::mergeNewAutoloadFunctions()(per-forked-worker bootstrapFiles stay), restored to the 2.2.8 semantics — every newly registered autoloader is appended to$GLOBALS['__phpstanAutoloadFunctions'], no prepended/appended split.Local e2e results after the revert:
Cannot redeclare function Redeclare\Builder\thing()— workflow step commented outThe two failing steps are commented out in
e2e-tests.yml(their e2e projects stay in the repo), so CI on this PR is expected to be green. Both tests were added by the commits being reverted — they cover behavior 2.2.8 never had.Unit tests, coding standard, lint and PHPStan self-analysis are green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NHfXXuWi9gKZ8daM2CeAyS