Permalink
Browse files

Fixed bug that can not get default value of parameter if it's not `op…

…tional`
  • Loading branch information...
1 parent 2b6ac9e commit 49b202f2cfe04d577671b685b7c0d3a096a433c7 @laruence laruence committed Aug 2, 2012
Showing with 7 additions and 4 deletions.
  1. +0 −4 ext/reflection/php_reflection.c
  2. +7 −0 ext/reflection/tests/bug62715.phpt
@@ -2406,10 +2406,6 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions");
return;
}
- if (param->offset < param->required) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional");
- return;
- }
precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error");
@@ -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)

0 comments on commit 49b202f

Please sign in to comment.