Re: [Vote] New in initializers

From: Date: Tue, 06 Jul 2021 10:58:08 +0000
Subject: Re: [Vote] New in initializers
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-115317@lists.php.net to get a copy of this message
On 06/07/2021 11:31, Benjamin Eberlei wrote:
This is not 100% correct, you can have an attribte #[Foo(Foo::class)] and then calling ReflectionAttribute::getArguments would also require to resolve the type Foo. So this is not different than what could happen right now already.
Despite its name, "::class" doesn't care about class definitions, it just performs a string substitution based on the "namespace" and "use" statements in the current file. In most cases, that happens entirely at compile time, so the following two source files compile identically: Short form: namespace Somebody\Something; #[ Foo( Foo::class ) ] class Whatever {} Expanded form: namespace Somebody\Something; #[ \Somebody\Something\Foo( '\Somebody\Something\Foo' ) ] class Whatever {} There is no need for the class \Somebody\Something\Foo to actually exist in either case, the argument is just a string: https://3v4l.org/bgNa2#v8.0.8 Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#115317) next »