Skip to content

token_get_all() lexes enum as T_STRING when a comment (not only whitespace) sits between it and the name #361

Closed

Description

@blacktrs

Summary

token_get_all() lexes enum as T_STRING when a comment (not only whitespace) sits between it and the name.

Repro

<?php
foreach (['enum /* c */ Foo {}', "enum/* c */Foo {}", "enum // c\nFoo {}", 'enum Foo {}'] as $src) {
    foreach (token_get_all('<?php ' . $src) as $t) {
        if (is_array($t) && $t[0] !== T_OPEN_TAG && $t[0] !== T_WHITESPACE) {
            echo token_name($t[0]), ' ';
            break;
        }
    }
}
echo "\n";

Expected (php)

T_ENUM T_ENUM T_ENUM T_ENUM 

Actual (manticore 1a1aa994, Darwin arm64)

T_STRING T_STRING T_STRING T_ENUM 

Tracking

Known-bug repro: tests/aot/repro/wrong/token_get_all_enum_comment_before_name.php — bash tests/aot/xfail.sh -k token_get_all_enum_comment_before_name reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions