Commit:    10642aa9e4f1eb694a8f7b514cc234cb24545744
Author:    Xinchen Hui <larue...@php.net>         Wed, 1 Aug 2012 20:23:30 +0800
Parents:   645f84e41bbda22c7a19326cd1a7df7994678976
Branches:  PHP-5.3

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=10642aa9e4f1eb694a8f7b514cc234cb24545744

Log:
Fixed bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result)

Bugs:
https://bugs.php.net/62715

Changed paths:
  M  NEWS
  M  ext/reflection/php_reflection.c
  A  ext/reflection/tests/bug62715.phpt


Diff:
diff --git a/NEWS b/NEWS
index 5aa35d7..b836d4f 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ PHP                                                          
              NEWS
 - DateTime:
   . Fixed Bug #62500 (Segfault in DateInterval class when extended). (Laruence)
 
+- Reflection:
+  . Fixed bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong
+    result). (Laruence)
+
 - SPL:
   . Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance
     gives Segmentation fault). (Laruence, Gustavo)
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e98652b..23c9044 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2379,9 +2379,7 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
        {
                RETURN_FALSE;
        }
-       if (param->offset < param->required) {
-               RETURN_FALSE;
-       }
+
        precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
        if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == 
IS_UNUSED) {
                RETURN_FALSE;
diff --git a/ext/reflection/tests/bug62715.phpt 
b/ext/reflection/tests/bug62715.phpt
new file mode 100644
index 0000000..721d484
--- /dev/null
+++ b/ext/reflection/tests/bug62715.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result)
+--FILE--
+<?php
+
+function test(PDO $a = null, $b = 0, array $c) {}
+$r = new ReflectionFunction('test');
+
+foreach ($r->getParameters() as $p) {
+    var_dump($p->isDefaultValueAvailable());
+}
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to