diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt')
-rw-r--r-- | ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt new file mode 100644 index 0000000..74044f7 --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt @@ -0,0 +1,69 @@ +--TEST-- +ReflectionClass::getInterfaces() - odd ampersand behaviour. +--CREDITS-- +Robin Fernandes <robinf@php.net> +Steve Seear <stevseea@php.net> +--FILE-- +<?php + +echo "An object is in an array and is referenced. As expected, var_dumping the array shows '&':\n"; +$a = array(new stdclass); +$b =& $a[0]; +var_dump($a); + +echo "Naturally, this remains true if we modify the object:\n"; +$a[0]->x = 1; +var_dump($a); + + +echo "\n\nObtain the array of interfaces implemented by C.\n"; +interface I {} +class C implements I {} +$rc = new ReflectionClass('C'); +$a = $rc->getInterfaces(); +echo "The result is an array in which each element is an object (an instance of ReflectionClass)\n"; +echo "Var_dumping this array shows that the elements are referenced. By what?\n"; +var_dump($a); + +echo "Modify the object, and it is apparently no longer referenced.\n"; +$a['I']->x = 1; +var_dump($a); + +?> +--EXPECTF-- +An object is in an array and is referenced. As expected, var_dumping the array shows '&': +array(1) { + [0]=> + &object(stdClass)#%d (0) { + } +} +Naturally, this remains true if we modify the object: +array(1) { + [0]=> + &object(stdClass)#%d (1) { + ["x"]=> + int(1) + } +} + + +Obtain the array of interfaces implemented by C. +The result is an array in which each element is an object (an instance of ReflectionClass) +Var_dumping this array shows that the elements are referenced. By what? +array(1) { + ["I"]=> + &object(ReflectionClass)#%d (1) { + ["name"]=> + string(1) "I" + } +} +Modify the object, and it is apparently no longer referenced. +array(1) { + ["I"]=> + object(ReflectionClass)#%d (2) { + ["name"]=> + string(1) "I" + ["x"]=> + int(1) + } +}
\ No newline at end of file |