php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44857 no property_exists() equivalent for magic properties
Submitted: 2008-04-28 18:05 UTC Modified: 2021-08-03 14:45 UTC
Votes:14
Avg. Score:4.5 ± 0.8
Reproduced:13 of 13 (100.0%)
Same Version:4 (30.8%)
Same OS:5 (38.5%)
From: mike at silverorange dot com Assigned: cmb (profile)
Status: Wont fix Package: Class/Object related
PHP Version: 5.2.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mike at silverorange dot com
New email:
PHP Version: OS:

 

 [2008-04-28 18:05 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-03 14:45 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: Class/Object related -Assigned To: +Assigned To: cmb
 [2021-08-03 14:45 UTC] cmb@php.net
> 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>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 06:23:17 2021 UTC