Repository navigation
perf(engine): create the parser and the name resolver on the first parse (4.x) - #239
Merged
Merged
Conversation
The composer "files" bootstrap of this package calls ReflectionEngine::init() on every request of an application that installs it, and init() built the PHP-Parser parser, lexer and name resolving traverser right away. Most requests never parse anything: in goaop/framework, parsing only happens on a cache miss. init() now only stores the locator and the grammar version, getParser() and parseFile() create the parser and the traverser on first use. The ComposerLocator stays eager on purpose: it must find composer's own class loader before other loaders wrap it. Warm request with opcache (built-in server, median of 200): requiring vendor/autoload.php of goaop/framework takes 87-91 instead of 229-242 µs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bYFRwMWKndKaj6SemwDn2
… master PHP 8.6 native reflection prints boolean constant values as "true" and "false" instead of the string casts "1" and "", so the experimental PHP 8.6 jobs of 4.x fail ReflectionClassTest::testGetReflectionConstant. Ported from the same rendering on master, with its PHPStan ignores for releases that do not know PHP 8.6 yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bYFRwMWKndKaj6SemwDn2
Member
Author
|
The experimental Master already handles it, so 2c6b46b ports only that rendering (true/false on PHP ≥ 8.6) and master's two PHPStan ignores to 4.x. The doc-comment prefix master added at the same place is left out. The new run on 2c6b46b will show whether the 8.6 jobs pass. Generated by Claude Code |
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.
What and why
Backport of #238 to the 4.x branch, which serves PHP 8.4 installs. Part of goaop/framework#730.
The composer
filesbootstrap runsReflectionEngine::init()on every request, andinit()built the PHP-Parser parser, lexer and name-resolving traverser right away. Nowinit()only stores the locator and grammar version, andgetParser()/parseFile()create them on first use.ComposerLocatorstays eager, because it must capture composer'sClassLoaderbefore other loaders wrap it. That saves about 145 µs per warm request, measured on master with PHP 8.5 and opcache.The commit is a clean cherry-pick of the master change, including the new
tests/ReflectionEngineTest.php.Tests
vendor/bin/phpstan analyse src: no errors.🤖 Generated with Claude Code
https://claude.ai/code/session_019bYFRwMWKndKaj6SemwDn2
Generated by Claude Code