Re: [RFC] [Discussion] Deprecate functions with overloaded signatures

From: Date: Tue, 02 May 2023 11:56:31 +0000
Subject: Re: [RFC] [Discussion] Deprecate functions with overloaded signatures
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-120177@lists.php.net to get a copy of this message
From the RFC: > > Code which invokes get_class() without parameters should be modified to > use __CLASS__ or get_class($this) instead, I don't think the first option is equivalent: class C { function printType() { echo "__CLASS__ is " . __CLASS__ . "\n"; echo "get_class is " . get_class($this) . "\n"; } } class D extends C { function printTypeInChild() { echo "__CLASS__ is " . __CLASS__ . "\n"; echo "get_class is " . get_class($this) . "\n"; } } (new D)->printType(); (new D)->printTypeInChild(); // Output is: __CLASS__ is C get_class is D __CLASS__ is D get_class is D And unless I'm missing something, the second option doesn't appear usable with static methods, which is also a problem with get_parent_class() > while code which invokes > get_parent_class() without parameters should be modified to use > get_parent_class($this) instead. What would the equivalent code get_parent_class() for static methods? e.g. class A {} class B extends A { public static function foo() { echo get_parent_class() . " \n"; } } b::foo(); cheers Dan Ack

« previous php.internals (#120177) next »