I have 2 classes MyClass and MyClass2. I need to call a new instance of MyClass using reflection, passing to the constructor an instance of MyClass2. This works fine until I try using the reference in MyClass2 constructor, $classObject
in this case will be null.
Why is this problem occurring? Knowing that this does not happen while testing a similar function call between two function within the same class!!
$className = 'MyClass';
$args = array(new MyClass2());
$classReflection = new ReflectionClass($className);
$classObject = classReflection->newInstanceArgs($args);
MyClass
public function __construct(&$myClass2)
Aucun commentaire:
Enregistrer un commentaire