Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122816 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 8001B1A009C for ; Sat, 30 Mar 2024 02:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711765249; bh=NNMFMI5HP4bvdzclpSdRaH2GJLkM4eSgKSfj0i0v9PE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=GaduSMiOHXTJk1tSmmRsnOlCRdqb5aKZ5u7QJ13hjv+170pAaukgCTuBTF7j14A/y csIPmd6jD7VZgs1O3hz7Hlos8ObMiaCVyq3Uzi5SGETN5yssEVEzSOXhcZY0rjDTKU K2gQFuacYuUDjenyVVtOeH5Q8VwZ7fvIeIHO6kGkBbhTm2UkqlVTWfc4vTIZhHTW8m 8za4VHZ1c5pT2PyhHwXg3kZmmzDogPz585EFg1pBpOvZBu7ua/glwzjuqXg0WPK8dZ LUW/8ruBTVzcjyo/u8gJZ/QyLwY9fgZmEbhuNmLRAVSznMK5U1bTc4woD9myfAfKIC jyu1wUrnPsDCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3772D180562 for ; Sat, 30 Mar 2024 02:20:47 +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.3 required=5.0 tests=BAYES_50,BODY_8BITS, DMARC_MISSING,SPF_HELO_NONE,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 gavin.smtp.mailx.hosts.net.nz (gavin.smtp.mailx.hosts.net.nz [43.245.52.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 30 Mar 2024 02:20:46 +0000 (UTC) Received: from 125-239-41-100-fibre.sparkbb.co.nz ([125.239.41.100] helo=[192.168.1.66]) by gavin.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1rqOKP-00176v-2I for internals@lists.php.net; Sat, 30 Mar 2024 15:20:17 +1300 Message-ID: <7e44a744-4151-4691-9911-afb8661167a1@varteg.nz> Date: Sat, 30 Mar 2024 15:20:06 +1300 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Invoke __callStatic when non-static public methods are called statically To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Hosts-DKIM-Check: none From: weedpacket@varteg.nz (Morgan) On 2024-03-30 13:06, 하늘아부지 wrote: > > Even currently, `__callStatic` is called in cases of non-static methods > that are not public methods. `__callStatic` already acts as a > rule-breaker. > I think the problem here is a confusion based on the idea that there is necessarily some direct correspondence between method names and strings passed to __callStatic. It's like confusing URLs with file paths. The fact that an object *may* have a private method named "foo" doesn't have any bearing on whether classname::foo() invokes __callStatic('foo') or not. The existence or otherwise of such methods in the class is irrelevant. __callStatic receives a string, and what it does with that string is entirely up to whoever is writing it. class First { protected static function test(): string { return "Calling First::test\n"; } } class Second extends First { public static function __callStatic(string $name, array $args): string { return "Calling callStatic::$name\n"; } public static function pass(): string { return Second::test(); // The inherited method } } echo Second::pass(); echo Second::test(); // Not the inherited method