Re: [RFC] Asymmetric Visibility, with readonly

From: Date: Thu, 05 Jan 2023 19:28:07 +0000
Subject: Re: [RFC] Asymmetric Visibility, with readonly
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-119234@lists.php.net to get a copy of this message
Hi Robert On Thu, Jan 5, 2023 at 3:54 PM Robert Landers <landers.robert@gmail.com> wrote: > > One quick question, > > Will changing the property of a protected/private set via reflection > be allowed? Or will you have to do some shenanigans like you currently > have to do with readonly? Since PHP 8.1 ReflectionProperty::setValue() allows writing to any property from any scope by default (assuming it is not readonly) without calling ReflectionProperty::setAccessible() first. https://wiki.php.net/rfc/make-reflection-setaccessible-no-op Essentially, there's no change to the existing behavior. You can write to an asymmetric property using setValue() just like you could to a protected or private property as the visibility check is skipped for these cases. I added a sentence to the RFCs reflection section to clarify. Thanks for pointing this out. Ilija

« previous php.internals (#119234) next »