ID:               43483
 Updated by:       [EMAIL PROTECTED]
 Reported By:      robin_fernandes at uk dot ibm dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: Windows
 PHP Version:      5.3CVS-2007-12-03 (snap)
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2008-02-02 14:02:43] [EMAIL PROTECTED]

I have reproduced the same issue on PHP 5.2.5 and PHP 5.3 (snapshot).
There is patch here:
http://jmcodex.com/patches/zend_builtin_functions.diff

But not sure if it is a bug itself due to lack of specifications on
docs.




------------------------------------------------------------------------

[2007-12-03 13:46:17] robin_fernandes at uk dot ibm dot com

The standard get_method handler (which is used to retrieve a method
before executing it) uses zend_check_protected() to verify whether a
protected method is accessible.
zend_check_protected() returns true if the current scope is the same
as, a child of OR a parent of the protected method's declaring class.

However, get_class_methods() implements its own algorithm to filter out
non visible methods.
This algorithm excludes protected methods unless the current scope is
an "instance of" the method's declaring class (so it is more restrictive
than zend_check_protected()):
[...]
if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC) 
 || (EG(scope) &&
     (((mptr->common.fn_flags & ZEND_ACC_PROTECTED) &&
       instanceof_function(EG(scope), mptr->common.scope TSRMLS_CC))
 || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
       EG(scope) == mptr->common.scope)))) {
[...]

------------------------------------------------------------------------

[2007-12-03 13:44:12] robin_fernandes at uk dot ibm dot com

Description:
------------
get_class_methods() should list accessible private and protected
methods if it is called from class scope (this is not stated explicitly
in the doc, but is mentioned in Dmitry's comment to bug 32296).

However, the testcase below shows a situation where, at a given scope,
a method is accessible yet not listed by get_class_methods().

Specifically, this occurs with protected methods accessed from a
superclass scope.

Reproduced on php53 and php6 snaps on Windows.

Reproduce code:
---------------
<?php
class C {
        public static function test() {
                D::prot();
                var_dump(get_class_methods("D"));
        }
}
class D extends C {
        protected static function prot() {
                echo "Successfully called D::prot().\n";
        }
}
C::test();
?>

Expected result:
----------------
Successfully called D::prot().
array(2) {
  [0]=>
  string(4) "prot"
  [1]=>
  string(4) "test"
}

Actual result:
--------------
Successfully called D::prot().
array(1) {
  [0]=>
  string(4) "test"
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43483&edit=1

Reply via email to