Skip to content

Handle the ::class static keyword as a special case in parser/variable.js#1138

Closed
mreiden wants to merge 1 commit intoglayzzle:mainfrom
mreiden:issue-1135
Closed

Handle the ::class static keyword as a special case in parser/variable.js#1138
mreiden wants to merge 1 commit intoglayzzle:mainfrom
mreiden:issue-1135

Conversation

@mreiden
Copy link
Contributor

@mreiden mreiden commented Aug 14, 2024

Handle T_Class as a special case when it comes after T_DOUBLE_COLON in recursive_variable_chain_scan

This solves #1135

$arrayVariable[0]::class;
$classVariable->classProp::class

Copy link
Member

@ichiriac ichiriac left a comment

Choose a reason for hiding this comment

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

The issue comes from the way PHP understands identifier https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L325

From a certain version, identifiers are composed also by reserved and semi reserved keywords :
https://github.com/glayzzle/php-parser/blob/main/src/parser/variable.js#L161

Here an example on how it's handled from php 7.0 :

@jorgsowa
Copy link
Collaborator

Alternative way of solution with tests: #1172

@czosel
Copy link
Collaborator

czosel commented Feb 22, 2026

Fixed via #1172 in v3.4.0

@czosel czosel closed this Feb 22, 2026
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.

4 participants