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?
You can use the __get()
function changing the scope of your property to private .
As the docs says:
__get() is utilized for reading data from inaccessible properties.
public function __get($field) {
if ($field == 'property') { //the name of your property
//do something that you want
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.