com php-src: fix: bug72222 for PHP-5.6 reflection export of array consts: ext/reflection/php_reflection.c ext/reflection/tests/Refl
ectionClass_export_array_bug72222.phpt

From: Date: Wed, 13 Jul 2016 19:39:55 +0000
Subject: com php-src: fix: bug72222 for PHP-5.6 reflection export of array consts: ext/reflection/php_reflection.c ext/reflection/tests/Refl
ectionClass_export_array_bug72222.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93001@lists.php.net to get a copy of this message
Commit: eb190b4e917e537380a505c4c28b9dc2c5b3c295 Author: nikita2206 <inefedor@gmail.com> Mon, 16 May 2016 02:58:21 +0300 Committer: Nikita Popov <nikic@php.net> Wed, 13 Jul 2016 21:39:55 +0200 Parents: 1896ca4e88451d5190d3ce921d6f7a52b3ec6e9f Branches: PHP-5.6 PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb190b4e917e537380a505c4c28b9dc2c5b3c295 Log: fix: bug72222 for PHP-5.6 reflection export of array consts Bugs: https://bugs.php.net/72222 Changed paths: M ext/reflection/php_reflection.c A ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt Diff: diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index fbcf7a7..5f15287 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -673,21 +673,26 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC) { char *type; - zval value_copy; - int use_copy; - type = zend_zval_type_name(value); - zend_make_printable_zval(value, &value_copy, &use_copy); - if (use_copy) { - value = &value_copy; - } + if (Z_TYPE_P(value) == IS_ARRAY) { + string_printf(str, "%s Constant [ %s %s ] { Array }\n", + indent, type, name); + } else { + zval value_copy; + int use_copy; - string_printf(str, "%s Constant [ %s %s ] { %s }\n", - indent, type, name, Z_STRVAL_P(value)); + zend_make_printable_zval(value, &value_copy, &use_copy); + if (use_copy) { + value = &value_copy; + } + + string_printf(str, "%s Constant [ %s %s ] { %s }\n", + indent, type, name, Z_STRVAL_P(value)); - if (use_copy) { - zval_dtor(value); + if (use_copy) { + zval_dtor(value); + } } } /* }}} */ diff --git a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt new file mode 100644 index 0000000...e64dc97 --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt @@ -0,0 +1,31 @@ +--TEST-- +ReflectionClass::export() - array constants +--FILE-- +<?php +Class A { + const A = 8; + const B = ["a", "b"]; +} +ReflectionClass::export("A"); +?> +--EXPECTF-- +Class [ <user> class A ] { + @@ %s 2-5 + + - Constants [2] { + Constant [ integer A ] { 8 } + Constant [ array B ] { Array } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +}

« previous php.cvs (#93001) next »