Cover the loader shapes the reverted autoloader attempts broke - #6293
Merged
Conversation
This was referenced Aug 27, 2026
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>
SanderMuller
force-pushed
the
e2e-autoloader-shapes
branch
from
August 27, 2026 20:34
6797a2a to
7132109
Compare
Member
|
Thank you! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test-only. No behaviour change -
src/is untouched.#6292 reverted five commits because, as you put it, every intervention in this area fixes one use case and breaks another. The problem for a future attempt is that only some of those breakages had an e2e project, so the next person gets no signal until a user reports it. These two projects pin the shapes that actually broke, using the real loaders rather than hand-rolled stand-ins.
598faaade(#6287 series)class-alias-loaderrobot-loaderBetween them they cover both eras of breakage, and neither duplicates an existing project.
class-alias-loaderuses the realtypo3/class-alias-loaderwithalways-add-alias-loader: it takes Composer's loader out of the queue and puts its own wrapper in, resolves a legacy name through a class alias map, and an IDE-only stub inside the analysed paths declares that same name as a plain class without the method. The alias has to win. On 2.2.9 the stub wins and PHPStan reports a missing method - the TYPO3 shape from phpstan/phpstan#15102, now with the actual package instead of my synthetic wrapper inbug-15102.robot-loaderregisters a NetteRobotLoaderover a directory Composer does not map, so only that loader can resolve the class (verified: without the bootstrap the project reports 2 errors, and the class has no Composer classmap entry). RobotLoader locks and writes a cache file while resolving, and on598faaadethat fails:because the loader runs while the file-read trap has replaced the
filestream wrapper. That is a shape none of the existing projects covered - an autoloader that writes during resolution - and it is the one I would have wanted before touching this code at all. It reproduces 3/3 runs, cold or warm cache, and with or without the explicitsetTempDirectory().Notes
bug-14988andbug-12972bstay commented out as you left them - they document Cannot redeclare function: AutoloadFunctionsSourceLocator includes PSR-4 function files untrapped phpstan#14988 and PHPStan autoloader mechanics invoked for case which does not use autoloading at runtime phpstan#14976, which are open.bug-12972c,bug-15102,bug-15102borbug-15102cred.