Re: Re: TOKEN_AS_OBJECT for token_get_all()
| From: | David Rodrigues | Date: | Fri, 24 Mar 2017 15:33:55 +0000 |
| Subject: | Re: Re: TOKEN_AS_OBJECT for token_get_all() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98618@lists.php.net to get a copy of this message | ||
Em 24 de mar de 2017 12:24 PM, "Andrea Faulds" <ajf@ajf.me> escreveu:
Hi Nikita,
Nikita Popov wrote:
I'd like to add a new TOKEN_AS_OBJECT flag to token_get_all(), which
> returns an array of PhpToken objects, rather than the mix of plain strings
> and arrays we currently have. The PhpToken class is defined as:
>
> class PhpToken {
> public $type;
> public $text;
> public $line;
> }
>
Rather than adding a flag to token_get_all() to return objects, you could
potentially instead make an equivalent static method on PhpToken
(PhpToken::getAll() perhaps). That would avoid mixing “object-oriented” and
“procedural” styles, though I don't know if it matters. It seems cleaner to
me.
I liked your suggestion. Maybe just change to something like
SplTokenizer::parse(): SplToken[]
Thanks!
--
Andrea Faulds
https://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php