|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45743 property_exists fails to find static protected member in child class
Submitted: 2008-08-07 09:57 UTC Modified: 2008-08-19 19:58 UTC
From: ilewis at uk dot ibm dot com Assigned: felipe
Status: Closed Package: Class/Object related
PHP Version: 5.3CVS-2008-08-07 (snap) OS: Fedora 8
Private report: No CVE-ID:
 [2008-08-07 09:57 UTC] ilewis at uk dot ibm dot com
property_exists() doesn't find a member in a child class when the member is static and protected.

The code below shows that the member is accessible and should be found by property_exists.

I've created a patch which I think fixes this, and put it here:

The patch was built against a CVS snap from today:

Reproduce code:
class aParent {
  public static function staticTest() {
    var_dump(property_exists("A", "prot"));

class A extends aParent { protected static $prot = "prot"; }

echo "\nparent scope:\n";

Expected result:
parent scope:
string(4) "prot"

Actual result:
parent scope:
string(4) "prot"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-07 10:18 UTC]
Send patches in unified diff format. (diff -u)
 [2008-08-07 12:36 UTC] ilewis at uk dot ibm dot com
I've put an updated diff -u output on pastebin:

I've also realised that this fix breaks testcase Zend/tests/bug42211.phpt, but I think this is a bug in the testcase, that is, it is testing for the broken behaviour.

I've put a patch for the testcase on pasetbin as well
 [2008-08-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-08-18 10:20 UTC] ilewis at uk dot ibm dot com
re-opening as I've submitted an updated patch
 [2008-08-18 16:51 UTC]
In fact, the property_exists() behave differently than method_exists().
 [2008-08-18 17:50 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

I've fixed the property_exists() behavior in 5_3 and HEAD. It now checks the existence, not the accessibility. (like the method_exists())

 [2008-08-19 08:11 UTC] ilewis at uk dot ibm dot com
That seems like a good fix, but the behaviour is now inconsistent with the docs :-) 

"This function checks if the given property exists in the specified class (and if it is accessible from the current scope)"

I guess that needs fixing up as well?
 [2008-08-19 11:01 UTC]
Sure, I've fixed it now, too. 

 [2012-02-17 13:30 UTC] kezliura at gmail dot com
Thanks, I just fixed my problem.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 05:01:34 2015 UTC