Skip to content

Commit 10642aa

Browse files
committed
Fixed bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result)
1 parent 645f84e commit 10642aa

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
- DateTime:
1414
. Fixed Bug #62500 (Segfault in DateInterval class when extended). (Laruence)
1515

16+
- Reflection:
17+
. Fixed bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong
18+
result). (Laruence)
19+
1620
- SPL:
1721
. Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance
1822
gives Segmentation fault). (Laruence, Gustavo)

ext/reflection/php_reflection.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,9 +2379,7 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
23792379
{
23802380
RETURN_FALSE;
23812381
}
2382-
if (param->offset < param->required) {
2383-
RETURN_FALSE;
2384-
}
2382+
23852383
precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
23862384
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) {
23872385
RETURN_FALSE;

ext/reflection/tests/bug62715.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result)
3+
--FILE--
4+
<?php
5+
6+
function test(PDO $a = null, $b = 0, array $c) {}
7+
$r = new ReflectionFunction('test');
8+
9+
foreach ($r->getParameters() as $p) {
10+
var_dump($p->isDefaultValueAvailable());
11+
}
12+
13+
?>
14+
--EXPECT--
15+
bool(true)
16+
bool(true)
17+
bool(false)

0 commit comments

Comments
 (0)