samedi 22 décembre 2018

PHP reflection of standard class value returns null

I hit a snag with code reflection PHP reflecting the standard class. I can demonstrate this with the snippet below.

The reflector correctly gets the property name (id)

Why does $id_property->getValue() return NULL? I would have expected 99.

$a = new \stdClass();
$a->id = 99;
$a_reflector = new \ReflectionObject($a);
$id_property = $a_reflector->getProperties()[0];
echo $id_property->getName(); //id
var_dump($id_property->getValue());





Aucun commentaire:

Enregistrer un commentaire