Req #44857 [Opn->Wfx]: no property_exists() equivalent for magic properties
| From: | cmb@php.net | Date: | Tue, 03 Aug 2021 14:45:26 +0000 |
| Subject: | Req #44857 [Opn->Wfx]: no property_exists() equivalent for magic properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235571@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44857&edit=1
ID: 44857
Updated by: cmb@php.net
Reported by: mike at silverorange dot com
Summary: no property_exists() equivalent for magic properties
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: Class/Object related
PHP Version: 5.2.5
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> It would return true iff __get($name) returns any value.
That would require to actually call __get(), what appears to be a
bad idea. Superseeding magic getters/setters with property
accessors[1] or similar appears to be the better option. Thus,
I'm closing as WONTFIX.
If you still feel that there should be a way to detect magic
getters/setters, please pursue the RFC process[2].
[1] <https://wiki.php.net/rfc/property_accessors>
[2] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2008-04-28 18:05:15] mike at silverorange dot com
Description:
------------
There is currently no way to determine if a magic __get() property exists.
The __isset() function should use 'isset(null) == false' semantics so it cannot be used to
reliably check if a magic property exists.
I propose a new magic method __property_exists($name) or __propertyExists($name) be created that
hooks into the property_exists() function. It would return true iff __get($name) returns any value.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44857&edit=1