Re: Reflection*::hasAttribute()

From: Date: Wed, 12 Jul 2023 22:05:27 +0000
Subject: Re: Reflection*::hasAttribute()
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-120799@lists.php.net to get a copy of this message
> > I think that would require an RFC. > > To clarify, you're proposing to replace this: > > count((new ReflectionClass(Beep::class))->getAttributes(Ignore::class)) == > true > > with > > (new ReflectionClass(Beep::class))->hasAttribute(Ignore::class) > > Right? That doesn't seem like a huge improvement. > > --Larry Garfield Actually, if ((new ReflectionClass(Beep::class))->getAttributes(Ignore::class)) would work as well, so basically: $rc->hasAttribute(Ignore::class) === (bool) $rc->getAttributes(Ignore::class); - Benjamin >

« previous php.internals (#120799) next »