I have a POPO (Plain Old PHP Object):
namespace App\Objects;
class POPO {
private $foo;
private $bar;
// getters and setters //
}
Elsewhere, I have a (Details - what the class does is unimportant) class that needs to know the names of the properties of POPO. POPO is not passed into this class, nor does this class instantiate POPO or care about the values of its properties.
class POPODetails {
private $POPOclassName = "App\Object\POPO"; //determined programatically elsewhere.
public getProperties(): array {
return get_class_vars($this->POPOClassName); //this will only return public properties.
}
}
To use get_object_vars
I would need to pass in an instantiated object, which I don't need otherwise, and would still only get public properties. I could use ReflectionClass::getProperties()
, but would also need to pass in an instantiated object.
So, is there a way to get a list of class vars using only the Fully Qualified Class Name?
Aucun commentaire:
Enregistrer un commentaire