1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00
Files
archived-php-src/ext/reflection/tests/bug62715.phpt
Nikita Popov 3b08f53c97 Deprecate required param after optional
As an exception, we allow "Type $foo = null" to occur before a
required parameter, because this pattern was used as a replacement
for nullable types in PHP versions older than 7.1.

Closes GH-5067.
2020-02-18 14:35:58 +01:00

26 lines
542 B
PHP

--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());
}
foreach ($r->getParameters() as $p) {
if ($p->isDefaultValueAvailable()) {
var_dump($p->getDefaultValue());
}
}
?>
--EXPECTF--
Deprecated: Required parameter $c follows optional parameter $b in %s on line %d
bool(true)
bool(true)
bool(false)
NULL
int(0)