<?php
class A {}
class B {
public function __construct(A $a = null)
{
}
public function test($a = null)
{
}
}
$r = new ReflectionMethod('B', 'test');
$p = $r->getParameters()[0];
var_dump($p->getName(), $p->allowsNull(), $p->getDefaultValue());
$r = new ReflectionMethod('B', '__construct');
$p = $r->getParameters()[0];
var_dump($p->getName(), $p->isDefaultValueConstant(), $p->allowsNull(), $p->getDefaultValue());
string(1) "a"
bool(true)
NULL
string(1) "a"
bool(false)
bool(true)
NULL
Output for 5.4.0 - 5.4.5
string(1) "a"
bool(true)
NULL
Fatal error: Call to undefined method ReflectionParameter::isDefaultValueConstant() in /in/E5eF4 on line 20
Process exited with code 255.
Parse error: syntax error, unexpected '[' in /in/E5eF4 on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/E5eF4 on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/E5eF4 on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/E5eF4 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/E5eF4 on line 5
Process exited with code 255.