Hi Robert

On Thu, Jan 5, 2023 at 3:54 PM Robert Landers <landers.rob...@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to