Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to parse classes with typed constants #1133

Open
davidrans opened this issue May 9, 2024 · 0 comments
Open

Fails to parse classes with typed constants #1133

davidrans opened this issue May 9, 2024 · 0 comments

Comments

@davidrans
Copy link

It looks like files that have typed constants are not parseable by the latest version (3.1.5).

Input file:

<?php

class Test {
   private const int MY_CONST = 3;
}

Error:

SyntaxError: Parse Error : syntax error, unexpected 'MY_CONST' (T_STRING), expecting '=' on line 4
    at Parser.raiseError (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser.js:349:17)
    at Parser.error (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser.js:397:15)
    at Parser.expect (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser.js:577:10)
    at Parser.read_constant_declaration (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/class.js:261:18)
    at Parser.read_list (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/utils.js:76:33)
    at Parser.read_constant_list (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/class.js:237:24)
    at Parser.read_class_body (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/class.js:117:32)
    at Parser.read_class_declaration_statement (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/class.js:32:30)
    at Parser.read_top_statement (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/statement.js:52:21)
    at Parser.read_start (/home/user/Code/node_modules/.pnpm/php-parser@3.1.5/node_modules/php-parser/src/parser/main.js:18:19) {
  lineNumber: 4,
  fileName: 'eval',
  columnNumber: 21
}
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

No branches or pull requests

1 participant