On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov <nikita....@gmail.com> wrote:

> Hi internals,
>
> This has been discussed a while ago already, now as a proper proposal:
> https://wiki.php.net/rfc/token_as_object
>
> tl;dr is that it allows you to get token_get_all() output as an array of
> PhpToken objects. This reduces memory usage, improves performance, makes
> code more uniform and readable... What's not to like?
>
> An open question is whether (at least to start with) PhpToken should be
> just a data container, or whether we want to add some helper methods to it.
> If this generates too much bikeshed, I'll drop methods from the proposal.
>
> Regards,
> Nikita
>

I've done some final updates to the RFC (
https://wiki.php.net/rfc/token_as_object) and intend to open voting
tomorrow, if there are major objections. The last changes were to clarify
that getTokenName() returns null for unknown token IDs, and to provide some
more extended rationale for what the individual methods are useful for.

@Michal: The reason why it's called PhpToken is that it is ... a PHP token
:) At least that's what it is intended to be used for -- while you could
technically use it to represent other kinds of tokens, I don't think that's
a usage that should be endorsed. Just "Token" is very generic, and not even
specific to lexing/tokenization. The term "Token" is commonly used in other
contexts as well (e.g. token ring).

Regards,
Nikita

Reply via email to