> > The next question that brings up then is in relation to bug#27798:
> >
> >  I would think that get_object_vars() should expose private/protected
props
> > when called from within the class itself (as appropriate based on
> > inheretance of course).  Is this assumption true?
>
> yeah, I think that's how it should work.
>
Then how does this patch look:

http://frankenbox.alphaweb.net/test/27798.diff

With the following script:

class A {
  public $a = 'A';
  protected $b = 'B';
  private $c = 'C';

  function look_from_a() {
    echo "From A: ";
    var_dump( get_object_vars($this) );
  }

}

class B extends A {

  function look_from_b() {
    echo "From B: ";
    var_dump( get_object_vars($this) );
  }

}

$b = new B();

$b->look_from_a();
$b->look_from_b();

echo "From outside the objects: ";
var_dump(get_object_vars($b));





It displays:



>From A: array(3) {
  ["a"]=>
  string(1) "A"
  ["b"]=>
  string(1) "B"
  ["c"]=>
  string(1) "C"
}
>From B: array(2) {
  ["a"]=>
  string(1) "A"
  ["b"]=>
  string(1) "B"
}
>From outside the objects: array(1) {
  ["a"]=>
  string(1) "A"
}




Everyone happy with that behavior?


-Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to