Browse Source
Fixed bug #40757 (get_object_vars get nothing in child class)
Fixed bug #40757 (get_object_vars get nothing in child class)
Fixed bug #41929 (Foreach on object does not iterate over all visible properties)experimental/5.2-WITH_DRCP
8 changed files with 74 additions and 24 deletions
-
3NEWS
-
4Zend/tests/bug27798.phpt
-
28Zend/tests/bug40757.phpt
-
24Zend/tests/bug41929.phpt
-
16Zend/zend_builtin_functions.c
-
2Zend/zend_object_handlers.c
-
20ext/pdo/tests/pdo_018.phpt
-
1tests/classes/visibility_005.phpt
@ -0,0 +1,28 @@ |
|||||
|
--TEST-- |
||||
|
Bug #40757 (get_object_vars() get nothing in child class) |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
class Base { |
||||
|
private $p1='sadf'; |
||||
|
|
||||
|
function getFields($obj){ |
||||
|
return get_object_vars($obj); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class Child extends Base { } |
||||
|
|
||||
|
$base=new Base(); |
||||
|
print_r($base->getFields(new Base())); |
||||
|
$child=new Child(); |
||||
|
print_r($child->getFields(new Base())); |
||||
|
?> |
||||
|
--EXPECT-- |
||||
|
Array |
||||
|
( |
||||
|
[p1] => sadf |
||||
|
) |
||||
|
Array |
||||
|
( |
||||
|
[p1] => sadf |
||||
|
) |
||||
@ -0,0 +1,24 @@ |
|||||
|
--TEST-- |
||||
|
Bug #41929 Foreach on object does not iterate over all visible properties |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
class C { |
||||
|
private $priv = "ok"; |
||||
|
|
||||
|
function doLoop() { |
||||
|
echo $this->priv,"\n"; |
||||
|
foreach ($this as $k=>$v) { |
||||
|
echo "$k: $v\n"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class D extends C { |
||||
|
} |
||||
|
|
||||
|
$myD = new D; |
||||
|
$myD->doLoop(); |
||||
|
?> |
||||
|
--EXPECT-- |
||||
|
ok |
||||
|
priv: ok |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue