Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108574 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39345 invoked from network); 14 Feb 2020 15:23:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Feb 2020 15:23:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 85E261804F8 for ; Fri, 14 Feb 2020 05:38:36 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 14 Feb 2020 05:38:35 -0800 (PST) Received: by mail-qk1-f173.google.com with SMTP id a2so9140457qko.12 for ; Fri, 14 Feb 2020 05:38:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/4y4FRledS4ZRJIRXL6WlWDbficI02NhDs188jgpPzw=; b=IJDp8XYUgeXvfNHIKnQWLVGWVHawJc+ghc6gYJQj6RwhkGo/1Lul5wYlixRlhtSLOM 6qRhu+Fu+90XlMlg2ClKbh4Za9BvhW1vpLi93TLJXU8g1xOwGF6V6k8Zi8CMPMwUPqXm aCSwtv3Smav/maS0p6NtbeLVE4Q0OCkfqS3vlWnGH2z6fpmScDvZYGb0FscGW0I0D0bi tB7bsviUdHkbAevjBQx8aU4+WWa8zL836yi6HAL+0FjgBF+EmIfSVabWyMjDW+e4DSlx RSTqTIpNik7x24CJJL454wkcex0gegRSCwUg8X6lQ2gjvWVXMJigV0Qs8k7UeOK+VUHi ZL6Q== X-Gm-Message-State: APjAAAVeg6Dds9RhCUwgK7qSUFwRpW/yD4dEInlDlmpaTTu03JPupOWa uyctaNsIFPyhieTuQHTnlxTQl/xYTKKpR8pfJxNv+g== X-Google-Smtp-Source: APXvYqw5BaK5iLXBbxqojzGS1oADA+nycKZX6RUxH49vLpMbmfnn9DJg1vfe/1Dn7HBdps1ME8eoSmsoNb4le5zmSPY= X-Received: by 2002:a05:620a:20c7:: with SMTP id f7mr2573819qka.440.1581687515072; Fri, 14 Feb 2020 05:38:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 14 Feb 2020 07:38:20 -0600 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000007b5ccc059e8952b2" Subject: Re: [PHP-DEV] [RFC] token_get_all() TOKEN_AS_OBJECT mode From: pollita@php.net (Sara Golemon) --0000000000007b5ccc059e8952b2 Content-Type: text/plain; charset="UTF-8" On Thu, Feb 13, 2020 at 3:48 AM Nikita Popov wrote: > This has been discussed a while ago already, now as a proper proposal: > https://wiki.php.net/rfc/token_as_object > > tl;dr is that it allows you to get token_get_all() output as an array of > PhpToken objects. This reduces memory usage, improves performance, makes > code more uniform and readable... What's not to like? > > An open question is whether (at least to start with) PhpToken should be > just a data container, or whether we want to add some helper methods to it. > If this generates too much bikeshed, I'll drop methods from the proposal. > > Yep. I remember bringing this up in 2016 and there was generally good reception to it from you, Andrea, Stas, and Stig at the very least. Why isn't it in? It got derailed by some bike shed colorizing and a little bit of workplace drama then dropped on the floor. Thanks for picking it up, and I agree with your response to Larry. As nice as it would be to lazy iterate, the scanner is just in NO shape to tolerate reentering userspace and potentially reinvoking the scanner before the first run through is done. I also agree that being able to subclass the token would be great, but that PDO made some mistakes here and we can do that as a separate addition later on if there's not consensus now. I'm +1 for NOT overloading the token_get_all() function, but rather putting a static factory method on the PhpToken class (or whatever you call it). When we add subclassability, we can always add additional statics if our initial signature doesn't work out. I'm not clear why you want to final the base constructor. IMO we populate the fields on object creation, then invoke constructor (which is a no-op in the base class). Later uses of subclassing can deal with the properties (or not) at that time, in their own constructor, delegating (or not) to the base. TL;DR +1, because I wanted this four years ago. :) -Sara --0000000000007b5ccc059e8952b2--