Skip to content

Support PHP 8.0's "Treat namespaced names as single token" change #327

Closed
@TysonAndre

Description

@TysonAndre

https://wiki.php.net/rfc/namespaced_names_as_token passed on July 31st. It makes the following changes to tokenization:

Foo\Bar;
// Before: T_STRING T_NS_SEPARATOR T_STRING
// After:  T_NAME_QUALIFIED
// Rule:   {LABEL}("\\"{LABEL})+
 
\Foo;
// Before: T_NS_SEPARATOR T_STRING
// After:  T_NAME_FULLY_QUALIFIED
// Rule:   ("\\"{LABEL})+
 
namespace\Foo;
// Before: T_NAMESPACE T_NS_SEPARATOR T_STRING
// After:  T_NAME_RELATIVE
// Rule:   "namespace"("\\"{LABEL})+

I think the simplest way to support existing applications might be to manually split up the T_NAME_* tokens into T_STRING, T_NAMESPACE, T_NS_SEPARATOR, etc after the call to token_get_all()

  • Other new syntax like T_MATCH or T_FN can have the same thing done to emulate that. Switches are fast in newer php versions when all arguments are definitely integers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions