cvs: ZendEngine2 / zend_builtin_functions.c /tests bug32296.phpt

From: Date: Tue, 03 May 2005 08:52:04 +0000
Subject: cvs: ZendEngine2 / zend_builtin_functions.c /tests bug32296.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3638@lists.php.net to get a copy of this message
dmitry Tue May 3 04:52:04 2005 EDT Modified files: /ZendEngine2 zend_builtin_functions.c /ZendEngine2/tests bug32296.phpt Log: Fixed bug #32296 (get_class_methods output has changed between 5.0.2 and 5.0.3) Now get_class_methods() shows accessible private and protected methods if it is called from class scope. http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.269&r2=1.270&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.269 ZendEngine2/zend_builtin_functions.c:1.270 --- ZendEngine2/zend_builtin_functions.c:1.269 Mon May 2 12:18:01 2005 +++ ZendEngine2/zend_builtin_functions.c Tue May 3 04:52:02 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.269 2005/05/02 16:18:01 helly Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.270 2005/05/03 08:52:02 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" @@ -812,7 +812,6 @@ zend_class_entry *ce = NULL, **pce; HashPosition pos; zend_function *mptr; - int instanceof; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -834,14 +833,16 @@ RETURN_NULL(); } - instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC); - array_init(return_value); zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC) - || (instanceof && ((mptr->common.fn_flags & ZEND_ACC_PROTECTED) || EG(scope) == mptr->common.scope))) { + || (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)))) { MAKE_STD_ZVAL(method_name); ZVAL_STRING(method_name, mptr->common.function_name, 1); zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); http://cvs.php.net/diff.php/ZendEngine2/tests/bug32296.phpt?r1=1.1&r2=1.2&ty=u Index: ZendEngine2/tests/bug32296.phpt diff -u /dev/null ZendEngine2/tests/bug32296.phpt:1.2 --- /dev/null Tue May 3 04:52:04 2005 +++ ZendEngine2/tests/bug32296.phpt Tue May 3 04:52:04 2005 @@ -0,0 +1,60 @@ +--TEST-- +Bug #32296 get_class_methods output has changed between 5.0.2 and 5.0.3 +--FILE-- +<?php +abstract class space{ + function __construct(){} + abstract protected function unfold(); +} + +abstract class shape extends space{ + private function x1() {} + protected final function unfold(){} +} + +abstract class quad extends shape{ + private function x2() {} + function buggy(){ + $c = get_class($this); + $a = get_class_methods(get_class($this)); + $b = get_class_methods($this); + print($c."\n".'a:'); + print_r($a); + print('b:'); + print_r($b); + } +} + +class square extends quad{} + +$a = new square(); +$a->buggy(); +print_r(get_class_methods("square")); +print_r(get_class_methods($a)); +?> +--EXPECT-- +square +a:Array +( + [0] => x2 + [1] => buggy + [2] => unfold + [3] => __construct +) +b:Array +( + [0] => x2 + [1] => buggy + [2] => unfold + [3] => __construct +) +Array +( + [0] => buggy + [1] => __construct +) +Array +( + [0] => buggy + [1] => __construct +)

« previous php.zend-engine.cvs (#3638) next »