Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123060 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 041CF1A009C for ; Tue, 9 Apr 2024 15:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712676296; bh=pJhyGZoUuKHAlgpQWu/4PiGlx8xAA7a5Ws40kcmrjvw=; h=In-Reply-To:References:Date:From:To:Subject:From; b=SdccyOYO7wea1QljmCp97xprdojM+b5xPll39TMO2N5EsEjRXiYgoXXquZxd4MbTD 3a1xadDEyd5fkV7TrrRdhIYSbVYXV2sQ0hKVAw5INnOgXShebi2Kl+9gTblwbQyxeB 8hmhSmhuX+K/b11bFinuex1EA0Upb/8/MXUmO7df5nl78Rfn3o6Dz5rDiPO0j1j5zj WDSNwG8osNjp0e4W/VhBXq3Pn9F68o5c4IV31pKKF/vEh1xy4SGvREkp+8jAV8KG1u BxE9EELtsCUg8VX+2MN8Xzd5rc7gMjyhyXZO6lgwO6RsYW1yHn4N7ow4JAmA/FrES7 JgqIORTnRzjAw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C91AD18006F for ; Tue, 9 Apr 2024 15:24:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 9 Apr 2024 15:24:55 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id F07051C00120 for ; Tue, 9 Apr 2024 11:24:21 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 09 Apr 2024 11:24:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1712676261; x= 1712762661; bh=xZPl2FnAqZZNE5z0a4JgmJpn+w2ppmcN2EcYOiwuUUY=; b=W Ay4lvatLhIquY4RBKt6cbUozNo7KeALXeT4+PklYQIYjuSzY0CirinabxqEeOPIL Vo5xLZymZdi/wgfLxrorjQ6LXf1Lt2+hQ4Agnf+KfWJbBWW/++dzfrvyr1uJJjLG sa15cTOVe2DtmM4ddfMj+VcFb2NJRQPpgRE1tXMYRnc469D/ffT8LAVLn2bPY5JZ /y6awHaOZBn78++rawyk8ADFyiQ/qjXr6WR7pVCaXXDHTFPcnUYOeWwzgkSIL8HV RFp4AhAwVBDdf1eICP0Oub3y1vvcA6OudAAva9BNCdwkpeRUJ01sB8KgAbFkH/6Q JXC0WQXI1IXU/yMNB/15Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712676261; x=1712762661; bh=xZPl2FnAqZZNE5z0a4JgmJpn+w2p pmcN2EcYOiwuUUY=; b=UtiqNLlfLJ3RJUr712ej0/PGBcddYZoBwIBLFSuMSc4d x72QLHCdHylittko8XPTRxeGXwwJ8UieskVjSHcDju1YOh9mCdjIBxZXXeIk+vsI LAt/9Gy4KAyyfnW8d4wQDWFYzTrITw/liiAPJgz7p5OfZhryaKI4lkoA3mCpQJkl KWw8cbImZRYaO1r9DU7ChjeUxSB72oV+18cqKA7VTrilHShCRWRkHk2B2ylvMURF RiOhBKzqJls9z2IFC9AvYKcMzfK2TiZQYlIFq+WxWC+WgZppMF70a6DCiuIypi7F ZGzNabGNsxnAkuU1vRqVWB3o2fIHXxYorc4ANZ0DIw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeduheettedtteehteeiheduheeukeeljefgtdeltdfg vdffueevieduffffkeduteenucffohhmrghinhepvgigthgvrhhnrghlshdrihhopdhphh hprdhnvghtpdhgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 212DD1700096; Tue, 9 Apr 2024 11:24:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-379-gabd37849b7-fm-20240408.001-gabd37849 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <0466054f-bbec-47fd-8452-e848ebec7ec9@app.fastmail.com> In-Reply-To: References: Date: Tue, 09 Apr 2024 15:23:59 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Mon, Apr 8, 2024, at 6:08 AM, Valentin Udaltsov wrote: > Hello internals, > > > > I would like to propose a syntax change for PHP 8.4 that allows to > immediately access instantiated objects without wrapping the expression > into parentheses. > > > > This was requested and discussed several times, see: > > - https://externals.io/message/66197 > > - https://bugs.php.net/bug.php?id=70549 > > - https://externals.io/message/101811 > > - https://externals.io/message/113953 > > > > Here's what you will be able to write after this change: > > ```php > > class MyClass > > { > > const CONSTANT = 'constant'; > > public static $staticProperty = 'staticProperty'; > > public static function staticMethod(): string { return 'staticMethod'; } > > public $property = 'property'; > > public function method(): string { return 'method'; } > > public function __invoke(): string { return '__invoke'; } > > } > > > > var_dump( > > new MyClass()::CONSTANT, // string(8) "constant" > > new MyClass()::$staticProperty, // string(14) "staticProperty" > > new MyClass()::staticMethod(), // string(12) "staticMethod" > > new MyClass()->property, // string(8) "property" > > new MyClass()->method(), // string(6) "method" > > new MyClass()(), // string(8) "__invoke" > > ); > > ``` > > > > For more details see the RFC: https://wiki.php.net/rfc/new_without_parentheses > > Implementation: https://github.com/php/php-src/pull/13029 I always thought there was some technical parser reason why this wasn't possible. Maybe that was true in 5.x but isn't anymore? I cannot speak to the implementation, but I'm all for the change itself. --Larry Garfield