com php-src: Fixed bug that can not get default value of parameter if it's not `optional`: ext/reflection/php_reflection.c ext/refle
ction/tests/ReflectionParameter_DefaultValueConstant_error .phpt ext/reflection/tests/bug62715.phpt
| From: | Xinchen Hui | Date: | Thu, 02 Aug 2012 14:28:04 +0000 |
| Subject: | com php-src: Fixed bug that can not get default value of parameter if it's not `optional`: ext/reflection/php_reflection.c ext/refle ction/tests/ReflectionParameter_DefaultValueConstant_error .phpt ext/reflection/tests/bug62715.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-69761@lists.php.net to get a copy of this message | ||
Commit: 170ee90bf962d288bdcf6cf0c8c4a2a30c5c1ba2
Author: Xinchen Hui <laruence@php.net> Thu, 2 Aug 2012 22:28:04 +0800
Parents: 3b5defd3b09bf827239087126261ce9abdc13d09
Branches: PHP-5.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=170ee90bf962d288bdcf6cf0c8c4a2a30c5c1ba2
Log:
Fixed bug that can not get default value of parameter if it's not
optional
Changed paths:
M ext/reflection/php_reflection.c
M ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
M ext/reflection/tests/bug62715.phpt
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 7e80dea..6656f58 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1477,11 +1477,6 @@ static parameter_reference
*_reflection_param_get_default_param(INTERNAL_FUNCTIO
return NULL;
}
- if (param->offset < param->required) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not
optional");
- return NULL;
- }
-
return param;
}
/* }}} */
@@ -1497,7 +1492,7 @@ static zend_op
*_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS
precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error");
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error: Failed to
retrieve the default value");
return NULL;
}
diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
index 984b06e...a2c2d24 100644
--- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
@@ -18,8 +18,6 @@ foreach($reflect->getParameters() as $param) {
}
}
?>
-==DONE==
--EXPECT--
-Parameter is not optional
+Internal error: Failed to retrieve the default value
CONST_TEST_1
-==DONE==
diff --git a/ext/reflection/tests/bug62715.phpt b/ext/reflection/tests/bug62715.phpt
index 721d484..feb67f6 100644
--- a/ext/reflection/tests/bug62715.phpt
+++ b/ext/reflection/tests/bug62715.phpt
@@ -10,8 +10,15 @@ foreach ($r->getParameters() as $p) {
var_dump($p->isDefaultValueAvailable());
}
+foreach ($r->getParameters() as $p) {
+ if ($p->isDefaultValueAvailable()) {
+ var_dump($p->getDefaultValue());
+ }
+}
?>
--EXPECT--
bool(true)
bool(true)
bool(false)
+NULL
+int(0)