Skip to content

Unexpected Token Exception for class name is thrown when using combination "readonly" and "final" or "readonly" and "abstract" #638

@EmilPDev

Description

@EmilPDev
  • PHP Depend version: 2.12.1
  • PHP Version: 8.2.0
  • Installation type: composer
  • Operating System / Distribution & Version: Docker image webdevops/php-nginx-dev
  • phpmd/phpmd 2.13.0

Current Behavior

Unexpected Token Exception for class name is thrown when using combination "readonly" and "final" or "readonly" and "abstract".

Expected Behavior

The same behavior as when you use the words separately.

Steps To Reproduce:

  1. Use combination of words "readonly" and "final" for declaration of class e.g. "final readonly class SmsStatusChecker" or "readonly final class SmsStatusChecker" or "abstract readonly class AbstractStringValueObject implements Stringable",...
  2. Run PHPMD command

Error log:
Unexpected token: readonly, line: 22, col: 7, file: /app/app/Service/SmsStatusChecker.php.
#0 /app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(7965): PDepend\Source\Parser\UnexpectedTokenException->__construct(Object(PDepend\Source\Tokenizer\Token), Object(PDepend\Source\AST\ASTCompilationUnit))

Checks before submitting

  • Be sure that there isn't already an issue about this. See: Issues list
  • Be sure that there isn't already a pull request about this. See: Pull requests
  • I have added every step to reproduce the bug.
  • If possible I added relevant code examples.
  • This issue is about 1 bug and nothing more.
  • The issue has a descriptive title. For example: "Default value is not available in AST when it's an array".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions