On Mon, Jan 4, 2016 at 2:56 PM, Sara Golemon <poll...@php.net> wrote: > https://wiki.php.net/rfc/token-get-always-tokens > A suggestion from a co-worker who's worried about seeing patterns like:
case ($t['token']) { case T_PAAMAYIM_NEKUDOTAYIM: // do something break; case ord(';'): // do something else break; } I see three options to remediate this: 1) We could offer constants like: T_SEMICOLON (or T_ASCII_SEMICOLON) defined to that character's ordinal value. (using unicode names) 2) Make the token field be the character value (for single-character tokens) instead of the ordinal. 3) Add an additional field such that you have Array ( ['id'] => 59, ['token'] => ';', ['text'] => ';', ['line'] => 1 ) 'id' would always be integer, while 'token' would be int or single-char. I don't like 3 as it's wasteful and needlessly duplicative. 1 feels a bit over-engineered and actually hurts readability. 2 feels like a nice compromise and matches how our rules end up looking in the parser anyway (since C treats single characters as ordinals already). -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php