<?php
namespace Rofl\Quack{
const BAR = "bar";
}
namespace Bar\Qux{
use const \Rofl\Quack\BAR;
const FOO = 1;
function whatever(
int $p0 = FOO,
int $p1 = BAR,
string $p2 = \Rofl\Quack\BAR . 'lit'
){}
}
namespace{
$RF = new ReflectionFunction(\Bar\Qux\whatever::CLASS);
var_dump($RF->getParameters()[0]->getDefaultValueConstantName());
var_dump($RF->getParameters()[1]->getDefaultValueConstantName());
var_dump($RF->getParameters()[2]->getDefaultValueConstantName());
}
- Output for 5.6.4 - 5.6.29, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- string(11) "Bar\Qux\FOO"
string(14) "Rofl\Quack\BAR"
NULL
- Output for 5.6.0 - 5.6.3
- Fatal error: Default value for parameters with a class type hint can only be NULL in /in/PGN2a on line 9
Process exited with code 255.
preferences:
132.52 ms | 401 KiB | 211 Q