Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90142 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85894 invoked from network); 5 Jan 2016 19:52:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2016 19:52:04 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.46 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.46 mail-lf0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:35056] helo=mail-lf0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/74-12097-2EE1C865 for ; Tue, 05 Jan 2016 14:52:02 -0500 Received: by mail-lf0-f46.google.com with SMTP id c192so124394809lfe.2 for ; Tue, 05 Jan 2016 11:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=NWp0AWhWE4uGu8WcvOdx3/CU5jW7/3hS4nz5pEiYuRk=; b=QNYznKDXclDMpaHR+eNB8GS6qGnhp/Xz0YA34YXYzypTvjjh3TsJrCnsrO/ZTb/mCm eVKdYJR1YBJ16nrsmBPnJUI453cbYNlmxXhuavrjgFvt+7rhsxDGVJaiDk3PENPpNtVT 75B7SDuVQEtPa5EtbPAzz75/KnYFPe6UdubSqe7pMoPuQSh4DEf3S6c6H72tygtVX22Q UjL+rKEm1+yuAou15adsbw8DGQ58kZSOM9Y+kHMQ7IL90RKBTeEkvB3n0ZpRiO06ct1v X+kT2b7w+9igwzNpbuIBlwrCaLkyFB0mkqJl+gduuZVKvOO2lad4Yu3nzlVFplfCHnDz RKDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=NWp0AWhWE4uGu8WcvOdx3/CU5jW7/3hS4nz5pEiYuRk=; b=TVL172il0Tef0jbRYfGEwskcctk1GYT/kAmZnOuc7kiGtmeIifcBJiCdAnHqX/6z3z T2vEl3Nqqis4MWrT2o9JOx15xlA7gSTUngfw0BieXFeyqKoBJ7RzAL+zdEhe+bxbEZz2 lBs/XixcD7u6Q3kaLWmOyfByqdTA+HLqoTTf92e67CFDQkzOpCB9kitk+lSmT+NxcLfg ikkWWx2HJtb6RzKoaZR7tjLhXqdh2ZNTSos/9Nn5RgnDCAa1m+KBL2emGx45m4EvNFVy SizYZCf9qI/QGyA7j+gDlZtf0Nzn2JsjxbOQcgFaPcHphDmMdu4x7zRqJq47kR6guUG6 7ryQ== X-Gm-Message-State: ALoCoQmvr4I51K0iwdRU3UFvAGM/jdFZhs+t5uIUq3pRNxw/kiG1IjtfFGbdNVWKlAF2t4UJxQDwqKKz5cNniuTv4ANobYx64Q== MIME-Version: 1.0 X-Received: by 10.25.65.5 with SMTP id o5mr24720256lfa.60.1452023518875; Tue, 05 Jan 2016 11:51:58 -0800 (PST) Sender: php@golemon.com Received: by 10.112.37.44 with HTTP; Tue, 5 Jan 2016 11:51:58 -0800 (PST) X-Originating-IP: [2620:10d:c090:200::6485] In-Reply-To: References: Date: Tue, 5 Jan 2016 11:51:58 -0800 X-Google-Sender-Auth: PBLyh0uXwp_YD2EJ4TXxG2sFkZE Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [RFC] Normalize token_get_all() output (with flag) From: pollita@php.net (Sara Golemon) On Mon, Jan 4, 2016 at 2:56 PM, Sara Golemon 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