Skip to content

Conversation

@rlerdorf
Copy link
Member

keywords like global, new, class are valid namespace identifiers. Everything except namespace works.

@rlerdorf rlerdorf merged commit 3274f21 into main Oct 24, 2025
5 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1877 to 1887
DelimitedList\QualifiedNameParts::class,
TokenKind::BackslashToken,
function ($token) {
// a\static() <- INVALID (but not checked for right now)
// new a\static() <- INVALID
// new static() <- VALID
// a\static\b <- INVALID
// a\function <- INVALID
// a\true\b <-VALID
// a\b\true <-VALID
// a\static::b <-VALID
// TODO more tests
return $this->lookahead(TokenKind::BackslashToken)
? in_array($token->kind, $this->nameOrReservedWordTokens)
: in_array($token->kind, $this->nameOrStaticOrReservedWordTokens);
if ($token->kind === TokenKind::NamespaceKeyword) {
return false;
}
return \in_array($token->kind, $this->nameOrKeywordOrReservedWordTokensExceptNamespace, true);
},
function ($parentNode) {
$name = $this->lookahead(TokenKind::BackslashToken)
? $this->eat($this->nameOrReservedWordTokens)
: $this->eat($this->nameOrStaticOrReservedWordTokens); // TODO support keyword name
$name = $this->eat($this->nameOrKeywordOrReservedWordTokensExceptNamespace); // TODO support keyword name
$name->kind = TokenKind::Name; // bool/true/null/static should not be treated as keywords in this case

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reinstate lookahead filtering for qualified-name keywords

The new parseQualifiedNameFn now accepts any keyword except namespace for every segment of a qualified name (in_array($this->nameOrKeywordOrReservedWordTokensExceptNamespace, true)). The previous implementation rejected keywords such as static or function when they were followed by another namespace separator, so constructs like new a\static() or a\function\b produced diagnostics. After this change those invalid identifiers parse as ordinary names, so the parser will silently accept syntactically invalid class or function references in non-namespace contexts. Consider keeping the lookahead logic and only broadening the allowed set where keywords are actually permitted (e.g. namespace declarations) to avoid suppressing errors elsewhere.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants