title: Check if a property exists on magically set properties
body: <p>There is a lot of SO questions about the subject, notably <a href="https://stackoverflow.com/questions/8763357/check-if-property-exists">this one</a>, but it does not help me.</p>
  
  <p>There is an ambiguity between <code>property_exists</code> and <code>isset</code> so before asking my question, I'm going to pointing it out:</p>
  
  <h2>property_exists</h2>
  
  <p><a href="http://php.net/manual/en/function.property-exists.php" rel="noreferrer">property_exists</a> checks if an object contains a property without looking at its value, it only looks at its <a href="http://php.net/manual/en/language.oop5.visibility.php" rel="noreferrer">visibility</a>.</p>
  
  <p>So in the following example:</p>
  
  <pre><code>&lt;?php
  
  class testA
  {
    private $a = null;
  }
  class testB extends testA
  {
  }
  
  $test = new testA();
  echo var_dump(property_exists($test, 'a')); // true
  
  // parent's private property becomes invisible for its child
  
  $test = new testB();
  echo var_dump(property_exists($test, 'a')); // false
  </code></pre>
  
  <h2>isset</h2>
  
  <p><a href="http://fr2.php.net/manual/en/function.isset.php" rel="noreferrer">isset</a> checks if a value exists in a property, considering that is is not set if a value equals <strike><code>false</code> and</strike> <code>null</code>.</p>
  
  <pre><code>&lt;?php
  
  $var = null;
  echo var_dump(isset($var)); // false
  
  $var = '';
  echo var_dump(isset($var)); // true
  
  $var = false;
  echo var_dump(isset($var)); // true
  
  $var = 0;
  echo var_dump(isset($var)); // true
  
  $var = '0';
  echo var_dump(isset($var)); // true
  </code></pre>
  
  <h2><code>isset</code> and <code>property_exists</code>'s behaviour on magically added properties</h2>
  
  <p>A property can exist with a <code>null</code> value, so I can't use <code>__isset</code> magic method to know if a property exist or not. I also can't use <code>property_exists</code> as properties are added using magic methods.</p>
  
  <p>Here is a sample, but this is just a sample because in my app, <strong>properties magically set are stored outside the object</strong>.</p>
  
  <pre><code>class test {
  
      private $data = array();
  
      public function __get($key) {
          echo "get $key\n";
          return array_key_exists($key, $data) ? $data[$key] : null;
      }
  
      public function __set($key, $value) {
          echo "set $key = $value\n";
          $this-&gt;data[$key] = $value;
      }
  
      public function __isset($key) {
         echo sprintf("isset $key ( returns %b )", isset($this-&gt;data[$key]));
         return isset($this-&gt;data[$key]);
      }
  
  }
  
  $test = new test();
  $test-&gt;x = 42;
  isset($test-&gt;x); // 1
  
  $test-&gt;y = null;
  isset($test-&gt;y); // 0
  property_exists($test, 'y'); // 0
  </code></pre>
  
  <p>So here is my question :</p>
  
  <blockquote>
    <p>Is there a magic method or an SPL interface to implement <code>property_exist</code> with magically added properties ?</p>
  </blockquote>