I was curious if this behavior was expected, it caught me by surprise.
A base object I use extends ArrayObject, that class is extended
heavily throughout my code and I recently wanted to use
get_object_vars, but noticed it returning an empty array. I do not
expect get_object_vars to return the properties I set via a
ArrayObject, but I would expect explicitly defined properties in
sub-classes and even in the ArrayObject extending class to be
returned. Is this thinking correct? If everyone agrees this is a bug I
can report it and write a patch  assuming its not a deep complicated
problem.

--Code
class TestOne {
  public $TestOne_1 = 1;
}

class TestTwo extends ArrayObject {
  public $TestTwo_1 = 1;
}

class TestThree extends TestTwo {
  public $TestThree_1 = 1;
}

$t1 = new TestOne;
var_dump((array) $t1, get_object_vars($t1));

$t2 = new TestTwo;
var_dump((array) $t2, get_object_vars($t2));

$t3 = new TestThree;
var_dump((array) $t3, get_object_vars($t3));

--Produces
array(1) {
  ["TestOne_1"]=>
  int(1)
}
array(1) {
  ["TestOne_1"]=>
  int(1)
}

array(0) {
}
array(0) {
}

array(0) {
}
array(0) {
}


Thanks,

-Chris

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

Reply via email to