I have a class that extends from Yii2's Model
and I need to declare a class public property in the constructor, but I'm hitting a problem.
When I call
class Test extends \yii\base\Model {
public function __constructor() {
$test = "test_prop";
$this->{$test} = null; // create $this->test_prop;
}
}
Yii tries to call, from what I understand, the getter method of this property, which of course doesn't exist, so I hit this exception.
Also, when I actually do $this->{$test} = null;
, this method gets called.
My question is: Is there a way to declare a class public property in another way? Maybe some Reflexion trick?
Aucun commentaire:
Enregistrer un commentaire