php - Get property call from parent class
I have the following code:
class Page extends APage{
/**
* @findby selector
*/
protected $property
public function getPropertyCount(){
count($this->property);
}
}
class APage{
protected function initPropertyByAnnotation(){
}
}
Im using selenium with php, In selenium you select an element with a selector. I want the parent class to detect a call to the childs property so i can handle the actual selecting.
I thought that this was possible through the __get magic method, but it turns out its only triggered when a property is not defined.
Is there a way to detect the call some way without using a helper method like getProperty?
Answer
Solution:
You can use the
__get()
function changing the scope of your property to private.As the docs says: