Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: ReflectionClass::getInterfaces() - odd ampersand behaviour.
        !             3: --CREDITS--
        !             4: Robin Fernandes <robinf@php.net>
        !             5: Steve Seear <stevseea@php.net>
        !             6: --FILE--
        !             7: <?php
        !             8: 
        !             9: echo "An object is in an array and is referenced. As expected, var_dumping the array shows '&':\n";
        !            10: $a = array(new stdclass);
        !            11: $b =& $a[0];
        !            12: var_dump($a);
        !            13: 
        !            14: echo "Naturally, this remains true if we modify the object:\n";
        !            15: $a[0]->x = 1;
        !            16: var_dump($a);
        !            17: 
        !            18: 
        !            19: echo "\n\nObtain the array of interfaces implemented by C.\n";
        !            20: interface I {}
        !            21: class C implements I {}
        !            22: $rc = new ReflectionClass('C');
        !            23: $a = $rc->getInterfaces();
        !            24: echo "The result is an array in which each element is an object (an instance of ReflectionClass)\n";
        !            25: echo "Var_dumping this array shows that the elements are referenced. By what?\n";
        !            26: var_dump($a);
        !            27: 
        !            28: echo "Modify the object, and it is apparently no longer referenced.\n";
        !            29: $a['I']->x = 1;
        !            30: var_dump($a);
        !            31: 
        !            32: ?>
        !            33: --EXPECTF--
        !            34: An object is in an array and is referenced. As expected, var_dumping the array shows '&':
        !            35: array(1) {
        !            36:   [0]=>
        !            37:   &object(stdClass)#%d (0) {
        !            38:   }
        !            39: }
        !            40: Naturally, this remains true if we modify the object:
        !            41: array(1) {
        !            42:   [0]=>
        !            43:   &object(stdClass)#%d (1) {
        !            44:     ["x"]=>
        !            45:     int(1)
        !            46:   }
        !            47: }
        !            48: 
        !            49: 
        !            50: Obtain the array of interfaces implemented by C.
        !            51: The result is an array in which each element is an object (an instance of ReflectionClass)
        !            52: Var_dumping this array shows that the elements are referenced. By what?
        !            53: array(1) {
        !            54:   ["I"]=>
        !            55:   &object(ReflectionClass)#%d (1) {
        !            56:     ["name"]=>
        !            57:     string(1) "I"
        !            58:   }
        !            59: }
        !            60: Modify the object, and it is apparently no longer referenced.
        !            61: array(1) {
        !            62:   ["I"]=>
        !            63:   object(ReflectionClass)#%d (2) {
        !            64:     ["name"]=>
        !            65:     string(1) "I"
        !            66:     ["x"]=>
        !            67:     int(1)
        !            68:   }
        !            69: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>