felipe                                   Wed, 26 May 2010 00:00:58 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=299766

Log:
- Fixed bug #51905 (ReflectionParameter fails if default value is an array with 
an access to self::)

Bug: http://bugs.php.net/51905 (Open) ReflectionParameter fails if default 
value is an array with an access to self::
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/Zend/zend_execute.h
    U   php/php-src/branches/PHP_5_2/Zend/zend_execute_API.c
    A   php/php-src/branches/PHP_5_2/ext/reflection/tests/bug51905.phpt
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/Zend/zend_execute.h
    U   php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c
    A   php/php-src/branches/PHP_5_3/ext/reflection/tests/bug51905.phpt
    U   php/php-src/trunk/Zend/zend_execute.h
    U   php/php-src/trunk/Zend/zend_execute_API.c
    A   php/php-src/trunk/ext/reflection/tests/bug51905.phpt

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_2/NEWS	2010-05-26 00:00:58 UTC (rev 299766)
@@ -19,6 +19,8 @@
   by Mateusz Kocielski. (Ilia)

 - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with
+- Fixed bug #51905 (ReflectionParameter fails if default value is an array
+  with an access to self::). (Felipe)
   constant array). (Felipe)
 - Fixed bug #51671 (imagefill does not work correctly for small images).
   (Pierre)

Modified: php/php-src/branches/PHP_5_2/Zend/zend_execute.h
===================================================================
--- php/php-src/branches/PHP_5_2/Zend/zend_execute.h	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_2/Zend/zend_execute.h	2010-05-26 00:00:58 UTC (rev 299766)
@@ -140,6 +140,8 @@
 }

 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_inline_change(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *arg TSRMLS_DC);
 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC);

 /* dedicated Zend executor functions - do not use! */

Modified: php/php-src/branches/PHP_5_2/Zend/zend_execute_API.c
===================================================================
--- php/php-src/branches/PHP_5_2/Zend/zend_execute_API.c	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_2/Zend/zend_execute_API.c	2010-05-26 00:00:58 UTC (rev 299766)
@@ -584,12 +584,22 @@
 			zend_hash_move_forward(Z_ARRVAL_P(p));
 			zval_dtor(&const_value);
 		}
-		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant_inline_change, (void *) scope TSRMLS_CC);
 		zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
 	}
 	return 0;
 }

+ZEND_API int zval_update_constant_inline_change(zval **pp, void *scope TSRMLS_DC)
+{
+	return zval_update_constant_ex(pp, (void*)1, scope TSRMLS_CC);
+}
+
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *scope TSRMLS_DC)
+{
+	return zval_update_constant_ex(pp, (void*)0, scope TSRMLS_CC);
+}
+
 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
 {
 	return zval_update_constant_ex(pp, arg, NULL TSRMLS_CC);

Added: php/php-src/branches/PHP_5_2/ext/reflection/tests/bug51905.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/reflection/tests/bug51905.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/reflection/tests/bug51905.phpt	2010-05-26 00:00:58 UTC (rev 299766)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
+--FILE--
+<?php
+
+class Bar {
+	const Y = 20;
+}
+
+class Foo extends Bar {
+	const X = 12;
+	public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+    if ( $param->isDefaultValueAvailable())
+        echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : 1
+$y : array (
+  0 => 12,
+)
+$z : 20


Property changes on: php/php-src/branches/PHP_5_2/ext/reflection/tests/bug51905.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_3/NEWS	2010-05-26 00:00:58 UTC (rev 299766)
@@ -64,6 +64,8 @@

 - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with
   constant array). (Felipe)
+- Fixed bug #51905 (ReflectionParameter fails if default value is an array
+  with an access to self::). (Felipe)
 - Fixed bug #51844 (checkdnsrr does not support types other than MX). (Pierre)
 - Fixed bug #51827 (Bad warning when register_shutdown_function called with
   wrong num of parameters). (Felipe)

Modified: php/php-src/branches/PHP_5_3/Zend/zend_execute.h
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_execute.h	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_3/Zend/zend_execute.h	2010-05-26 00:00:58 UTC (rev 299766)
@@ -135,6 +135,8 @@
 }

 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_inline_change(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *arg TSRMLS_DC);
 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC);

 /* dedicated Zend executor functions - do not use! */

Modified: php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c	2010-05-26 00:00:58 UTC (rev 299766)
@@ -684,13 +684,25 @@
 			}
 			zval_dtor(&const_value);
 		}
-		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant_inline_change, (void *) scope TSRMLS_CC);
 		zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
 	}
 	return 0;
 }
 /* }}} */

+ZEND_API int zval_update_constant_inline_change(zval **pp, void *scope TSRMLS_DC) /* {{{ */
+{
+	return zval_update_constant_ex(pp, (void*)1, scope TSRMLS_CC);
+}
+/* }}} */
+
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *scope TSRMLS_DC) /* {{{ */
+{
+	return zval_update_constant_ex(pp, (void*)0, scope TSRMLS_CC);
+}
+/* }}} */
+
 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC) /* {{{ */
 {
 	return zval_update_constant_ex(pp, arg, NULL TSRMLS_CC);

Added: php/php-src/branches/PHP_5_3/ext/reflection/tests/bug51905.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/reflection/tests/bug51905.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/reflection/tests/bug51905.phpt	2010-05-26 00:00:58 UTC (rev 299766)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
+--FILE--
+<?php
+
+class Bar {
+	const Y = 20;
+}
+
+class Foo extends Bar {
+	const X = 12;
+	public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+    if ( $param->isDefaultValueAvailable())
+        echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : 1
+$y : array (
+  0 => 12,
+)
+$z : 20


Property changes on: php/php-src/branches/PHP_5_3/ext/reflection/tests/bug51905.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/Zend/zend_execute.h
===================================================================
--- php/php-src/trunk/Zend/zend_execute.h	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/trunk/Zend/zend_execute.h	2010-05-26 00:00:58 UTC (rev 299766)
@@ -156,6 +156,8 @@
 }

 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_inline_change(zval **pp, void *arg TSRMLS_DC);
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *arg TSRMLS_DC);
 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC);

 /* dedicated Zend executor functions - do not use! */

Modified: php/php-src/trunk/Zend/zend_execute_API.c
===================================================================
--- php/php-src/trunk/Zend/zend_execute_API.c	2010-05-25 23:18:13 UTC (rev 299765)
+++ php/php-src/trunk/Zend/zend_execute_API.c	2010-05-26 00:00:58 UTC (rev 299766)
@@ -684,13 +684,25 @@
 			}
 			zval_dtor(&const_value);
 		}
-		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
+		zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant_inline_change, (void *) scope TSRMLS_CC);
 		zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
 	}
 	return 0;
 }
 /* }}} */

+ZEND_API int zval_update_constant_inline_change(zval **pp, void *scope TSRMLS_DC) /* {{{ */
+{
+	return zval_update_constant_ex(pp, (void*)1, scope TSRMLS_CC);
+}
+/* }}} */
+
+ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *scope TSRMLS_DC) /* {{{ */
+{
+	return zval_update_constant_ex(pp, (void*)0, scope TSRMLS_CC);
+}
+/* }}} */
+
 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC) /* {{{ */
 {
 	return zval_update_constant_ex(pp, arg, NULL TSRMLS_CC);

Added: php/php-src/trunk/ext/reflection/tests/bug51905.phpt
===================================================================
--- php/php-src/trunk/ext/reflection/tests/bug51905.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/reflection/tests/bug51905.phpt	2010-05-26 00:00:58 UTC (rev 299766)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
+--FILE--
+<?php
+
+class Bar {
+	const Y = 20;
+}
+
+class Foo extends Bar {
+	const X = 12;
+	public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+    if ( $param->isDefaultValueAvailable())
+        echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : 1
+$y : array (
+  0 => 12,
+)
+$z : 20


Property changes on: php/php-src/trunk/ext/reflection/tests/bug51905.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to