Skip to content

Commit

Permalink
Merge pull request pdepend#656 from pdepend/fix/enum-keywords
Browse files Browse the repository at this point in the history
Base enum label validity on constant name rule
  • Loading branch information
tvbeek committed Mar 3, 2023
2 parents 31be7cd + c1cd664 commit 9b74d9a
Showing 1 changed file with 2 additions and 7 deletions.
Expand Up @@ -8173,17 +8173,12 @@ private function parseEnumCase()
$this->tokenStack->add($this->tokenizer->next());
$this->tokenStack->push();
$this->consumeComments();
$caseName = $this->tokenizer->currentToken()->image;

if (in_array($this->tokenizer->peek(), array(
Tokens::T_NEW,
Tokens::T_NULL,
Tokens::T_STRING,
Tokens::T_DEFAULT
), true) === false) {
if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $caseName)) {
throw $this->getUnexpectedTokenException();
}

$caseName = $this->tokenizer->currentToken()->image;
$this->tokenStack->add($this->tokenizer->next());
$this->consumeComments();
$case = $this->builder->buildEnumCase($caseName, $this->parseEnumCaseValue());
Expand Down

0 comments on commit 9b74d9a

Please sign in to comment.