Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108956 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41185 invoked from network); 10 Mar 2020 17:58:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Mar 2020 17:58:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 19E0E1804DF for ; Tue, 10 Mar 2020 09:19:02 -0700 (PDT) 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.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS12876 195.154.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from smtp.opensides.be (smtp.opensides.be [195.154.20.141]) by php-smtp4.php.net (Postfix) with ESMTP for ; Tue, 10 Mar 2020 09:19:01 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp.opensides.be (Postfix) with ESMTP id 869274A2253 for ; Tue, 10 Mar 2020 17:18:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at opensides.be Received: from smtp.opensides.be ([127.0.0.1]) by localhost (smtp.opensides.be [127.0.0.1]) (amavisd-new, port 10024) with LMTP id SyyrzI1ScCej for ; Tue, 10 Mar 2020 17:18:57 +0100 (CET) Received: from mcmic-probook.opensides.be (63.120.199.77.rev.sfr.net [77.199.120.63]) by smtp.opensides.be (Postfix) with ESMTPSA id 143D94A2251 for ; Tue, 10 Mar 2020 17:18:57 +0100 (CET) To: internals@lists.php.net Date: Tue, 10 Mar 2020 17:18:54 +0100 Message-ID: <8165930.V9hoPP6r1K@mcmic-probook> Organization: FusionDirectory User-Agent: KMail/5.2.3 (Linux/4.9.0-12-amd64; KDE/5.28.0; x86_64; ; ) In-Reply-To: References: <1715830.3Z3xILz1Hf@mcmic-probook> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [VOTE] Object-based token_get_all() alternative From: come.chilliet@fusiondirectory.org (=?ISO-8859-1?Q?C=F4me?= Chilliet) Le mardi 10 mars 2020, 15:53:41 CET Nikita Popov a =C3=A9crit : > Would __toString() return $token->text? I'm not strictly opposed to this, > but I'd be hard pressed to think of a situation where I would prefer > writing (string) $token over $token->text. Generally, the less magic the > better :) My idea was that since tokens are parsed from a string it should be easy to= write a string back with them. I do not have an obvious usecase but the idea is doing stuff like if ($token.is('function')) { echo "public $token"; } else { echo $token; } Am I right to assume that with __toString the same as ->text we=E2=80=99d h= ave implode('', PhpToken::getAll($code)) =3D=3D $code ? This would allow: $tokens =3D PhpToken::getAll($code); // Modifications on $tokens $code =3D implode('', $tokens); =2D-=20 C=C3=B4me Chilliet =46usionDirectory - https://www.fusiondirectory.org