Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode
| From: | Levi Morrison via internals | Date: | Fri, 14 Feb 2020 00:27:45 +0000 |
| Subject: | Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108556@lists.php.net to get a copy of this message | ||
On Thu, Feb 13, 2020 at 2:48 AM Nikita Popov <nikita.ppv@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
Overall it looks great. Thanks, Nikita.
I do think it should use a separate function from
token_get_all, and
am not sure I care whether it is a function or static method.
The only helper I see as totally non-controversial is getTokenName,
which seems completely reasonable and users should not have to keep
re-implementing that. I am open to more discussion about the others.