Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122801 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 A08921A009C for ; Fri, 29 Mar 2024 09:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711705446; bh=44Ctdt0yjZulCDOPTXbJy5GKo0gWBaGPf7HJ36uN4eo=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=FFx7U1fSe+BM1sAwKc4O+NQVkrwfEDU9A12YhhRKmOzKZ2skZdtygQHJcGppOhAIJ fJdP4Lt+axhx6ovP0IPTOdrJfg0Y5Bi4qcUAnkMFMoWpYNrOqTZk2+cguaSNJUV2BL FSFmIibnzXDZXtc8MCrsPOaKvonkjJbIxppmRwfQRuYWK7t9d2FAmTJN5csS/Zi3LQ PV2WLfet1vUQQcfwgihYX+GSLDV8Oko3kLVkqno5XUTnDll4CUqLqNElh7HP88yY5b ekjt7R/NgMisJidnqBBgZctYz6Q5ZbIYj979jzxg6uqINlyB1AaRy4/L96sRgehe+2 OTZyTUMVbzXMA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 11DB818004D for ; Fri, 29 Mar 2024 09:44:04 +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=2.1 required=5.0 tests=BAYES_50,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) (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 ; Fri, 29 Mar 2024 09:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chstudio.fr; s=protonmail2; t=1711705414; x=1711964614; bh=44Ctdt0yjZulCDOPTXbJy5GKo0gWBaGPf7HJ36uN4eo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=lO47F+kf0cnoDiCWxiZkDD7jpjmXW9OMJdt7dDirOu8S06yXDZWQGEtx6JZGF0t9r whfq6hXg5tOSAJZCH13PuFowUxofFyWv+Cl2tXiY+CkhZGwzUDq/pKVdAKYWSNU09k DbHKa5b+C+XRGNnrFCZ9LC2xjK7+p3QWSpnhDqCWkv8bWds91IaKpmYCwZ1uaBE0Mj JdjAHOwpR6/NPvCknEV3wXsZWwZs3/4yDJeu4aD/jDNbc4RjT6+/BEbuiiGblfYDF/ ECkKTsyNg0ZZxeC141WDy0+AqMZ/O23ODEyiufErtpRxD9M+b4rot2mciRIjpV35cl ZqCh3cilBnxSA== Date: Fri, 29 Mar 2024 09:43:28 +0000 To: =?utf-8?B?7ZWY64qY7JWE67aA7KeA?= Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Invoke __callStatic when non-static public methods are called statically Message-ID: In-Reply-To: References: Feedback-ID: 41282912:user:proton Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha512; boundary="------4f06def30944c9099cf5fb7b7ce724f3dccae01ede032970d83b8e82b2f4dacb"; charset=utf-8 From: s.hulard@chstudio.fr (=?utf-8?Q?St=C3=A9phane_Hulard?=) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------4f06def30944c9099cf5fb7b7ce724f3dccae01ede032970d83b8e82b2f4dacb Content-Type: multipart/mixed;boundary=---------------------15a7e482d53382868421eb0a350dba4b -----------------------15a7e482d53382868421eb0a350dba4b Content-Transfer-Encoding: quoted-printable Content-Type: text/plain;charset=utf-8 Le vendredi 29 mars 2024 =C3=A0 03:39, =ED=95=98=EB=8A=98=EC=95=84=EB=B6=80= =EC=A7=80 a =C3=A9crit=C2=A0: > Hello. > = > I created a wiki for __callStatic related issues. > Please see: > https://wiki.php.net/rfc/complete_callstatc_magic > = > I look forward to your interest and advice. > = > Best Regards. > Daddyofsky Hello ! I took a look at your proposal and I think about important issues if we go= this way. A static method mustn't used the `$this` variable because it simply doesn'= t exists in the static context. The examples you're adding in the RFC are = fine but they always rely to a specific `__callStatic` implementation that= will use a new instance of the object to forward the call. There are multiple cases where it'll be complicated to use it this way. Tw= o of them I have in mind: - What if the object needs important parameters in its constructor that ar= en't available in the static context ? Or those parameters need to be init= ialized outside of the `__callStatic` method? - What if the underlying non static method we are trying to invoke is usin= g the `$this` variable? In those two examples, I would prefer having a fatal error that explains t= hat I'm not doing the call correctly (calling a non static method in the s= tatic context) to ensure it'll be easy to understand and fix. The use cases you are describing here have been fixed in the user space by= the Laravel team. It's a very specific way of working that's mostly speci= fic to Laravel. For sure it makes the code harder to read since you can't jump to a real m= ethod easily (because most of the methods are magic ones and are forwarded= to underlying objects). I don't tell it's wrong but I'm not sure it's rel= evant to make the whole language simplify this process. If there is a way to work correctly with those static vs non static calls = and capture relevant errors to expose them to users, that's fine. However, I think this is an important behavior change because it'll allow = a new way to work with method that were forbidden before. Regards St=C3=A9phane -----------------------15a7e482d53382868421eb0a350dba4b-- --------4f06def30944c9099cf5fb7b7ce724f3dccae01ede032970d83b8e82b2f4dacb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wnUEARYKACcFgmYGjS8JkFAFamSXyqbjFiEEAbZnit5cX2dsfkYRUAVqZJfK puMAAO/OAP9NWqADeWG5od0I0P3hxbUOnKYsI0IyEFbnPCig6YHrDAD9Ee2H SZb20/WKMhEiGwQe08J4t5K5ejeU1EBxR3yGjg4= =Eo2z -----END PGP SIGNATURE----- --------4f06def30944c9099cf5fb7b7ce724f3dccae01ede032970d83b8e82b2f4dacb--