Skip to content

token_get_all() splits a reserved keyword followed by a backslash name (use\C, new\X) instead of one T_NAME_QUALIFIED #363

Closed

Description

@blacktrs

Summary

token_get_all() splits a reserved keyword followed by a backslash name (use\C, new\X) instead of one T_NAME_QUALIFIED.

Repro

<?php
foreach (['<?php use\C;', '<?php $a = new\X;', '<?php function\f();', '<?php echo\A\b();'] as $src) {
    $out = [];
    foreach (token_get_all($src) as $t) {
        if (is_array($t) && $t[0] !== T_OPEN_TAG && $t[0] !== T_WHITESPACE) {
            $out[] = token_name($t[0]) . ' ' . $t[1];
        }
    }
    echo implode(' | ', $out), "\n";
}

Expected (php)

T_NAME_QUALIFIED use\C
T_VARIABLE $a | T_NAME_QUALIFIED new\X
T_NAME_QUALIFIED function\f
T_NAME_QUALIFIED echo\A\b

Actual (manticore 44b91556, Darwin arm64)

T_USE use | T_NAME_FULLY_QUALIFIED \C
T_VARIABLE $a | T_NEW new | T_NAME_FULLY_QUALIFIED \X
T_FUNCTION function | T_NAME_FULLY_QUALIFIED \f
T_ECHO echo | T_NAME_FULLY_QUALIFIED \A\b

Tracking

Known-bug repro: tests/aot/repro/wrong/token_get_all_keyword_backslash_name.php — bash tests/aot/xfail.sh -k token_get_all_keyword_backslash_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