You can crack the constraint by creating a wrapper that uses Reflection so that you can access all the properties and methods. You can use it like this:
$self = new FullAccessWrapper($this); function () use ($self) { }
Here's a sample shell implementation, taken from here :
class FullAccessWrapper { protected $_self; protected $_refl; public function __construct($self) { $this->_self = $self; $this->_refl = new ReflectionObject($self); } public function __call($method, $args) { $mrefl = $this->_refl->getMethod($method); $mrefl->setAccessible(true); return $mrefl->invokeArgs($this->_self, $args); } public function __set($name, $value) { $prefl = $this->_refl->getProperty($name); $prefl->setAccessible(true); $prefl->setValue($this->_self, $value); } public function __get($name) { $prefl = $this->_refl->getProperty($name); $prefl->setAccessible(true); return $prefl->getValue($this->_self); } public function __isset($name) { $value = $this->__get($name); return isset($value); } }
Obviously, the above implementation does not cover all aspects (for example, it cannot use magic properties and methods).
NikiC Jun 17 2018-11-11T00: 00Z
source share