title: How can I delete a property from a parent object in an extended class?
body: <p>I am attempting to write a "listener" on a variable in a class I cannot modify. I am extending the class in question, unsetting the properties I want to listen to, and then using __set to intercept writes to that variable. At that point I compare with the previous version and report if there are changes.</p>
  
  <pre><code>class A {
      var $variable;
  
      ...
  }
  
  class B extends A {
      var $new_variable
  
      function __construct() {
          parent::__construct();
          unset($this-&gt;variable);
      }
  
      function __set($thing, $data) {
          if ($thing == 'variable') {
              // Report change
              // Set $new_variable so we can use __get on it
          }
      }
  
      public function __get($var) {
          if (isset($this-&gt;$var)) {
              // Get as normal.
              return $this-&gt;$var;
          } elseif ($var == 'variable' &amp;&amp; isset($this-&gt;new_variable)) {
              return $this-&gt;new_variable;
          }
      }
  
      ...
  }
  </code></pre>
  
  <p>This works if I modify the class in question directly instead of via an extended class, removing the declaration of the variable and introducing the setter and getter methods. The problem is when I use the pattern shown above, the unset() call does not seem to actually remove the variables inherited from the parent class, thus rendering the __set method unable to intercept the variable's value.</p>
  
  <p>So far this seems to me to be the only way I can watch the variables changes, but I do not want to hack the core of the framework, only inspect it's handy work (a parser).  Is there a possibility of making this work, or another way to approach this problem?</p>