Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90462 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35775 invoked from network); 10 Jan 2016 21:13:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2016 21:13:59 -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.43 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.43 mail-lf0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:34500] helo=mail-lf0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/40-14657-599C2965 for ; Sun, 10 Jan 2016 16:13:58 -0500 Received: by mail-lf0-f43.google.com with SMTP id 17so1031381lfz.1 for ; Sun, 10 Jan 2016 13:13:57 -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=1xcLQkVzjjHBbabgvLxP6SvQp/P/G8nzQZhajMnjmU0=; b=f57AV48M+MP3x4d47rvP+SZsWEPx2gaWYO3+NJi1cwBZYqna8fts5D0RBQUd7uHtpV 4/HZlqGEn18raCM4W5FIsGYxhhcutRGd81f7hOdQihXHTEub+cgZVSB+vSYvx39t9oJW /f6U5YWg15TGWK5RgKdvx38EvmAszqUjiOMu7qxWPFim5asHZy2TrMV52+DA+ozhpr4D XvF8glsrdmrLpPMVIqgAos8OrbTD+L7AaJCY2wchfJhbsoBox0SM5B+w+rgjiwG/NxQL 3m5oq4pWTBcmXCFFoxef5XdHK36ZnE1p/ZUCyo+4Ek1UKYk7I4qV4F+khk3IqfuHatOy ko7g== 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=1xcLQkVzjjHBbabgvLxP6SvQp/P/G8nzQZhajMnjmU0=; b=H4/apeiS/qkKCyk4YyTtujI7XqVA/2LJ0jqzdfHPmKKudhQOmMrAsn3mEkshbdE1lc xNtn5peOL4LH0TuAzZIZenVFhltjgPQZIp9yLd5tsytN+Iut5n3jasuUUttK5YTDsj5k MLO23hOtSPvCqVe5mlUGMrGwuAaptWJEhOthWBKs5jhOwdduvYO42+Kopu/6YNVMyplF nyJBt8nT/IzxaxRgaUi/+B0Iu4mkT23FtIr1vQqtjvcUxTbYzpMSDZnhcPmUYDTAreU2 HTpAcRWz7WsAvHnxDy0k7WN6niiVqN/V0dEPmuKU333VB9M0G1Ddz3yCnIkNSdctEFTp WA2A== X-Gm-Message-State: ALoCoQmYOkA21Cgon+p4BHqrg4u4tSOiEudWgunsF2SuRC//ebrixOzuIM+5Flo3i/sT/wZfXwWZr3EDR0Z2r65TsUtxtga1Og== MIME-Version: 1.0 X-Received: by 10.25.91.139 with SMTP id p133mr24557601lfb.108.1452460433977; Sun, 10 Jan 2016 13:13:53 -0800 (PST) Sender: php@golemon.com Received: by 10.112.37.44 with HTTP; Sun, 10 Jan 2016 13:13:53 -0800 (PST) X-Originating-IP: [2620:10d:c090:180::f572] In-Reply-To: References: Date: Sun, 10 Jan 2016 13:13:53 -0800 X-Google-Sender-Auth: n-ajaOwg6Oxc5N-ZOwLeRwPVnzk 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 Tue, Jan 5, 2016 at 11:51 AM, Sara Golemon wrote: > 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). > Never really got a response on this one, and I'm personally leaning further towards Option 2; So unless someone has a better idea, I'll update the RFC in a few days. -Sara