Repository navigation
Conversation
A name followed by an asterisk with no space in between is now read as a ConstFetchNode with an empty class name and the pattern as its name, the way Foo::BAR_* already is for class constants: PHP_ROUND_*, E_*_ERROR, Foo\BAR_*. Such a PHPDoc was invalid until now, so nothing that parsed before parses differently. The asterisk has to touch the name, which is what keeps "@return string *Note:* text" a type followed by a description. The grammars tell an asterisk written right after a name apart as T_NAME_WILDCARD, so that they read the same language. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
This makes a global constant name written with asterisks parse, the way
Foo::BAR_*already does for class constants:A name followed by an asterisk with no space in between is read as a
ConstFetchNodewith an empty class name and the pattern as its name:new ConstFetchNode('', 'PHP_ROUND_*'). This is the parser half of phpstan/phpstan#7272; the PHPStan half, which resolves the pattern to the matching constants, is phpstan/phpstan-src#6995.Merge after phpstan/phpstan-src#6995. The "Test PHPStan" job runs phpstan-src
2.3.xwith this parser, and its existing tests already write@param FILTER_VALIDATE_* $intFilter, which now parses and makesTypeNodeResolverthrowShouldNotHappenExceptionuntil that PR is in. "Test Slevomat Coding Standard" fails on2.4.xitself as well (NameNode), independently of this change.Nothing that parsed before parses differently. Such a PHPDoc was an
InvalidTagValueNodeuntil now. The asterisk has to touch the name, which is what keeps@return string *Note:* texta type followed by a description (there is a test for that). Keywords stay invalid as before:null*,true*andarray*are still errors.What changes:
ConstExprParser: after a name, a glued*starts a pattern. The loop that readsFoo::BAR_*moved intoparseConstantNamePattern(), which both forms use.TypeParser:isConstantFetchAfterName()decides whether a name starts a constant expression (::, or now a glued*). Both the main path and the callable-return-type path use it, socallable(): FOO_*works likecallable(): Foo::*.T_NAME_WILDCARD/T_NAME_WILDCARD_WS, andConstantFetch, the type-name lookaheads and the free-text tokens accept it. The fuzzer knows how to write it.GrammarSyncTestrejects the new test inputs without these grammar changes, and the whole suite passes with them.🤖 Generated with Claude Code