Req #80328 [NEW]: PhpToken::getAll() confusing name
| From: | david at grudl dot com | Date: | Fri, 06 Nov 2020 14:02:49 +0000 |
| Subject: | Req #80328 [NEW]: PhpToken::getAll() confusing name | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-230166@lists.php.net to get a copy of this message | ||
From: david at grudl dot com
Operating system:
PHP version: 8.0.0RC3
Package: SPL related
Bug Type: Feature/Change Request
Bug description:PhpToken::getAll() confusing name
Description:
------------
I'm really excited about PHP 8 and it's great that
object-based alternatives come into language, such as token_get_all().
As you know, there are only 2 hard problems in computer science: cache
invalidation, naming things, and off-by-1 errors.
And this is about naming things :-)
How to call method, whose task is to parse PHP code into tokens? I think
it's a good name is
parse(), even better is tokenize(). But it's
definitely not a name get(), because it obscures what the function
does. Get is for getters.
We can add other more specific words to the verb when tokenize($code)
is not descriptive, like tokenizeFile(). But what means getAll()? Is
there any other option than to get them all?
getAll() is just an unfortunate name. Side by side with classic getter
getTokenName() method - they're similarly named and do a diametrically
different job.
For static constructor, also "from" notation might be used, ie
PhpToken::fromString(), but please change getAll() to something better
:)
BTW: ReflectionAttribute::IS_INSTANCEOF should really be
ReflectionAttribute::IS_INSTANCE_OF
--
Edit bug report at https://bugs.php.net/bug.php?id=80328&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80328&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80328&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80328&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80328&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80328&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80328&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80328&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80328&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80328&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80328&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80328&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80328&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80328&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80328&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80328&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80328&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80328&r=mysqlcfg