I am using PHP Reflection to read a file. In that file, there are two classes are passed as a dependency like following:
private $books;
private $genres;
function __construct(Book $books, Genre $genres)
{
$this->books= $books;
$this->genres= $genres;
}
I can get the type and name of the constructor parameters like this.
$class = new ReflectionClass('AdminClass');
$parameters = $class->getConstructor()->getParameters();
foreach ($parameters as $param) {
echo $parameter->name."<br>";
echo $param->getType()."<br>";
}
Now, i want to get the object where the specific class is instantiated. Such as, here, inside the constructor $this->books
represents as a Book
class object, $this->genres
represents Genre
class object.
So i want to get $this->books
.
How can i get the objects names ?
Aucun commentaire:
Enregistrer un commentaire