Re: [RFC] isReadable/isWriteable property reflection
| From: | Tim Düsterhus | Date: | Fri, 07 Nov 2025 11:03:38 +0000 |
| Subject: | Re: [RFC] isReadable/isWriteable property reflection | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129131@lists.php.net to get a copy of this message | ||
Hi
Am 2025-11-06 00:24, schrieb Larry Garfield:
In other news, Ilija and I said a year ago that we'd take a swing at adding isReadable/isWriteable methods to ReflectionProperty. Took a while, but here we are. A strangely small RFC from us: https://wiki.php.net/rfc/isreadable-iswriteableI dislike implicitly “scope-dependent” functions, since they effectively act like magic. This probably makes it harder to understand for humans and static analysis tools alike. I would therefore suggest making the
$scope parameter required. A user can just pass static::class themselves and static analysis tools can use class-string|null instead of class-string|"static"|null as their expected parameter type.
As for the magic method logic: I would suggest to ignore the presence of __get() and __set(). This more closely aligns with the direction PHP goes towards and is also easy to work around by checking with method_exists() whether any such a method exists - the reverse is not true.
Best regards
Tim Düsterhus