Beispiel #1
0
 /**
  * To remove a property from the instance.
  *
  * Data management : In PHP7, \Closure::bind(), \Closure::bindTo() and \Closure::call()
  * can not change the scope about non real closure (all closures obtained by \ReflectionMethod::getClosure()) to avoid
  * error due to compilation pass with self::
  *
  * Thise change does not impact rebinding of $this, but the scope stay unchanged, and private or protected attributes
  * or method are not available in this closure (the scope differ).
  *
  * So we use magic call to restore this behavior during a calling
  *
  * @param string $name
  *
  * @throws \ErrorException of the property is not accessible
  */
 public function __unset(string $name)
 {
     if (!$this->callerStatedClassesStack->isEmpty() && property_exists($this, $name)) {
         unset($this->{$name});
         return;
     }
     if ($this->isPublicProperty($name)) {
         unset($this->{$name});
         return;
     }
     throw new \ErrorException('Error: Cannot access private property ' . get_class($this) . '::' . $name);
 }