Comments (5)
Note: it happens with any PHP keyword (e.g. "CLASS", "INTERFACE"...) and is case insensitive (e.g. "CLASS", "Class", "class" all result in a fatal error).
Example test file (test.php):
<?php
enum Test
{
case CLASS;
}
Running the following command:
phpmd test.php ansi cleancode
Results in:
ERROR while parsing
--------------------
Unexpected token: use, line: 5, col: 10, file: /var/www/html/test.php.
#0 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(7966): PDepend\Source\Parser\UnexpectedTokenException->__construct(Object(PDepend\Source\Tokenizer\Token), Object(PDepend\Source\AST\ASTCompilationUnit))
#1 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(8116): PDepend\Source\Language\PHP\AbstractPHPParser->getUnexpectedTokenException()
#2 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1099): PDepend\Source\Language\PHP\AbstractPHPParser->parseEnumCase()
#3 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion81.php(164): PDepend\Source\Language\PHP\AbstractPHPParser->parseTypeBody(Object(PDepend\Source\AST\ASTEnum))
#4 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6578): PDepend\Source\Language\PHP\PHPParserVersion81->parseEnumDeclaration()
#5 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(516): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalStatement()
#6 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(606): PDepend\Source\Language\PHP\AbstractPHPParser->parse()
#7 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(351): PDepend\Engine->performParseProcess()
#8 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php(99): PDepend\Engine->analyze()
#9 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(240): PHPMD\Parser->parse(Object(PHPMD\Report))
#10 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php(136): PHPMD\PHPMD->processFiles('test.php', 'phpmd.xml.dist', Array, Object(PHPMD\RuleSetFactory), Object(PHPMD\Report))
#11 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php(184): PHPMD\TextUI\Command->run(Object(PHPMD\TextUI\CommandLineOptions), Object(PHPMD\RuleSetFactory))
#12 /var/www/html/vendor/phpmd/phpmd/src/bin/phpmd(61): PHPMD\TextUI\Command::main(Array)
#13 /var/www/html/vendor/bin/phpmd(120): include('/var/www/html/v...')
#14 {main}
from pdepend.
The error also occurs when the enum's member is named Null.
from pdepend.
Note: it happens with any PHP keyword (e.g. "CLASS", "INTERFACE"...) and is case insensitive (e.g. "CLASS", "Class", "class" all result in a fatal error).
Example test file (test.php):
<?php enum Test { case CLASS; }
php -l test.php
Result in: PHP Fatal error: A class constant must not be called 'class'; it is reserved for class name fetching in test.php on line 4
Error parsing test.php
That means class isn't allowed.
This are valid names for constants but not yet handled by PDepend.
- DEFAULT
- NEW
- NULL
from pdepend.
I got the same error for enum name CONTINUE
from pdepend.
Same for parent
.
from pdepend.
Related Issues (20)
- Values of hnd and hnt are mixed up in XML report HOT 1
- Response for a class (RFC) measure HOT 4
- Critical Error: A compilation unit should contain at least one token HOT 3
- Typo in encoding name HOT 4
- Invalid characters passed to "octdec" HOT 1
- Compatibility Issue with Symfony/Config v7.0.0 in `getConfigTreeBuilder` Method HOT 10
- Broken Interface Type for Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder HOT 2
- Missing .phar's HOT 1
- Major version 3.0.0 HOT 2
- Fail to parse throw exception in key offset access
- Trait method collision error for valid php file
- TooManyPublicMethods ignore exceptions HOT 1
- Use of "Parent" in namespace triggers "Unexpected token: Parent".
- Backed enum expects the type to be all lowercase HOT 2
- `Unexpected token: |` when using union typed constants HOT 4
- "Unexpected token: [" error when accessing array constant item HOT 2
- Cannot load xml namespace for validating config HOT 2
- FIlter pattern exclude regression HOT 7
- Handle comments when parsing expressions
- MathUtil usage in NPathComplexityAnalyzer HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdepend.