Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117613 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54714 invoked from network); 26 Apr 2022 10:00:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Apr 2022 10:00:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A81AA180539 for ; Tue, 26 Apr 2022 04:36:09 -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=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 ; Tue, 26 Apr 2022 04:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1650972967; bh=ZM51GavL1aUSgWdX+U0Jp+sSyY2oIqPH8n/iXBTRogU=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=Rk6JiN+KA0HzdhlMXdmLNBeE/M5xzkcsEYlX+irKQOx4OTgXiQnm2CCPhVo3cet38 5j++Dhk25Epe0QLZCJlxGMPVhfLZuX+SMp1fMdif8Hhjli/OJijBRBUnILDybln0+N 39mu8axbW75N+TTW8Z6rjS0ya4WieS/EFtNtcWho= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([79.251.216.99]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MN5iZ-1nQH473pR7-00J5yx; Tue, 26 Apr 2022 13:36:06 +0200 Message-ID: <2499e7be-318f-54a6-5f44-7c62e6be4332@gmx.de> Date: Tue, 26 Apr 2022 13:36:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: de-DE To: chopins xiao , "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:/9Meoq96KT55hPrB1oHO4DfVIRSogEDP8Wz1wKJox/BTQqEHAG0 G90xHWRVh36owtPKmKBv8ACtPpdHJB56B2Tbd7FLqtCn24O27zvuiVP8poUCsRggs3Lxdp7 JKb0il1ZY2J5wy9OEggSvWCotUPArE5PB47NnMx705EodEQHL8Huk3D0QsEh0+5KQEgOG8L MDM6l1FumzmffoY9G2ByQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:Zq1PwSOvAb8=:xbTfAZ32u23yUl+oMDe2rX jD8XA/VaSj0cingeu/1xNFnLFLC6XO/bLQYjOLQohDdRcEkMUA074WMUw2I2OiiMXobQTr++c Yu5SpBOApG42pTaI5G3vKLO8UcvRAJDWRDPZyWIxZ+SeMiQM0V7qqwkE3kpwpsCfOYPVTG4Aa qHwhx/TuKrJ1G+bJ7kRnDen6wcX54DUutYHaXzaV7CrznYd5pA6ImBu4Sxp/Szrvm0Pdp87Bc Z8xEtlX5HQ9sd2BGiQ0Yly8QnnPEIzmq9o9klO2NyHDhB0vzMnnS58H8/PTI94dVXSFjxAy+l /F3LlZcGPGYlpTv4VZBQdTyEDO+vVpFKBeL0KQszCqaaPm7silTubH6PBuWQVsjPZHKCOExWJ zY8y1xLwO3iwPPu2t/OC9Urx14PA89YTJcAUyrGq734Ou5F7Z5A+YxiqDOGGx+QBXeAKn38sL 2IKu4iiUxLHtwdOyk0kIAoO9Thnq3xm0Z7nuBKwSnbv7AnixChzbaU2pYNqU/omQgXOzzonCH zqly4uQ4K6BuvkqllNWJanc9gnDnOpmWu9jjB34xMkF1B7nqpCHY8Ocd0+cnaqlORvRwjnma/ vptcSNoystThdXbzTqXXoMmPSeHefE/d5v1MuF9qtvTHFhr+mzGGrpHu6z9228PDyIcFaz8K4 wWoT5HhNDZUaRqqVRhLEcVEj5uTUJkZmR+1Gk0RcW9yjsYQE86EX1wuWamdvVLpAkhQmg8Clr KnxEoNmQAFqrqhvxgFZhY8UrGiu5SUI6Y4GfVq087ERwZY7Q27O+bQhEfybhI72qYM8BmfE2r MHWO/lINfmg+bmSiZ4NxQw4ZIq1yP8L51Z/voWCmNvJeu+cTzLdVFUypfygkwGkqhs7cSnUN4 pHaiRb6QX1OIxj/J5bj04L5g70Gny7+XOA2pVUvT1Zrob34fMP25ahNFVBNdIYAfjwdVtac/V paFr2cwRxWNaQyQZ4HGRqBaryjuRLzX0kjSMr25DVdR2sJG/mG2FF2MIuFfvkSm23zclGSZow d0qTCgs4hzaiGEG8H0qjipD7mWJZ1EBILqH6E9/C+DQoEsr7EXw/Y1iNmJesBMTCsDLavtXLc IjidfocZ5fVIvQ= Subject: Re: Add another php syntax for simplify code From: cmbecker69@gmx.de ("Christoph M. Becker") On 26.04.2022 at 06:02, chopins xiao wrote: > 0. when dot object opeator is enable, use small sign and add sign [<+] = be equivalent to [.] for string concat mark. > compatibility is achieved through configuration switches. > syntax =EF=BC=9A > >>> $a =3D 'str0'; > >>> $a .=3D 'str1' <+ 'str2' <+ 'str3' <+ $str_var <+ strcall(= ); > the concat equal sign[.=3D] not change > > 1. use dot mark[.] same with [->] > syntax: > >>> $a =3D new stdClass; > >>> $a.b =3D1; same with $a->b =3D 1 when dot object opeat= or is enable in php.ini > >>> $a.get(); same with $a->get() when dot object opeator = is enable in php.ini > > 2. colon [:] same with [=3D>] in array declaration statement > syntax: > >>> $a =3D [ 'b' : 1, 'c' : 3 ]; same with $a =3D ['b'=3D>1, = 'c' =3D> 3] > > 3. another class declaration statement, cant not use [extends] and [imp= lement] keyword > syntax: > >>> class Objects(ParentClass): Interface1,Interface2 {} > same with > >>> class Objects extends ParentClass implement Interface1,Int= erface2 {} > > anonymous class > >>> $obj =3D new($arg1,$arg2) class(ParentClass) : implement In= terface1,Interface2 {} > same with > >>> $obj =3D new class($arg1,$arg2) extends ParentClass impleme= nt Interface1,Interface2{} > > 5. another class method declaration statement, omit [function] keyword = is allowable > syntax: > >>> public method_name($args) {} > same with > >>> public function method_name($args) {} > > 6. restriction public magic method synax sugar, omit [public][function] = keywords and duoble underline[__] is allowable, only __get() __set() __ca= ll() __callStatic() __toString() __sleep() __wakeup() __serialize() __= unserialize() is availabled > syntax: > >>> class A { > >>> get() { > >>> } > >>> call() { > >>> } > >>> } > same with: > >>> class A { > >>> public function __get() { > >>> } > >>> public function __call() { > >>> } > >>> } > > The implement and syntax see: > https://github.com/chopins/php-src/blob/fast_grammar/FastSyntax.md In my opinion, it is generally a bad idea to support different syntax based on an INI setting. This easily leads to confusion for those reading the code. I don't see much point in these "simplifications" anyway, except maybe for the shorter array literals. Note though, that there has been RFC[1] about a similar syntax, but that had been declined. [1] =2D- Christoph M. Becker