When using the ReflectionClass
to loop through native PHP class __construct()
parameters, I've noticed that the names of the parameters in the docs aren't matching up to what I'm getting using the ReflectionParameter
class methods.
For example the DateTime
object:
$reflector = new ReflectionClass('DateTime');
$constructor = $reflector->getConstructor();
if ($constructorParams = $constructor->getParameters()) {
foreach ($constructorParams as $i => $param) {
var_dump($param->getClass());
}
}
This outputs:
null
null
But according to the docs the class description is:
public DateTime::__construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
Shouldn't the $timezone
parameter have a type hint of DateTimeZone
? Or is the parameter not actually type hinted, and rather just telling you what should be passed in?
Aucun commentaire:
Enregistrer un commentaire