Annotation of embedaddon/php/tests/lang/engine_assignExecutionOrder_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Evaluation order during assignments.
! 3: --FILE--
! 4: <?php
! 5:
! 6: function f() {
! 7: echo "in f()\n";
! 8: return "name";
! 9: }
! 10:
! 11: function g() {
! 12: echo "in g()\n";
! 13: return "assigned value";
! 14: }
! 15:
! 16:
! 17: echo "\n\nOrder with local assignment:\n";
! 18: ${f()} = g();
! 19: var_dump($name);
! 20:
! 21: echo "\n\nOrder with array assignment:\n";
! 22: $a[f()] = g();
! 23: var_dump($a);
! 24:
! 25: echo "\n\nOrder with object property assignment:\n";
! 26: $oa = new stdClass;
! 27: $oa->${f()} = g();
! 28: var_dump($oa);
! 29:
! 30: echo "\n\nOrder with nested object property assignment:\n";
! 31: $ob = new stdClass;
! 32: $ob->o1 = new stdClass;
! 33: $ob->o1->o2 = new stdClass;
! 34: $ob->o1->o2->${f()} = g();
! 35: var_dump($ob);
! 36:
! 37: echo "\n\nOrder with dim_list property assignment:\n";
! 38: $oc = new stdClass;
! 39: $oc->a[${f()}] = g();
! 40: var_dump($oc);
! 41:
! 42:
! 43: class C {
! 44: public static $name = "original";
! 45: public static $a = array();
! 46: public static $string = "hello";
! 47: }
! 48: echo "\n\nOrder with static property assignment:\n";
! 49: C::${f()} = g();
! 50: var_dump(C::$name);
! 51:
! 52: echo "\n\nOrder with static array property assignment:\n";
! 53: C::$a[f()] = g();
! 54: var_dump(C::$a);
! 55:
! 56: echo "\n\nOrder with indexed string assignment:\n";
! 57: $string = "hello";
! 58: function getOffset() {
! 59: echo "in getOffset()\n";
! 60: return 0;
! 61: }
! 62: function newChar() {
! 63: echo "in newChar()\n";
! 64: return 'j';
! 65: }
! 66: $string[getOffset()] = newChar();
! 67: var_dump($string);
! 68:
! 69: echo "\n\nOrder with static string property assignment:\n";
! 70: C::$string[getOffset()] = newChar();
! 71: var_dump(C::$string);
! 72:
! 73: ?>
! 74: --EXPECTF--
! 75:
! 76:
! 77: Order with local assignment:
! 78: in f()
! 79: in g()
! 80: %string|unicode%(14) "assigned value"
! 81:
! 82:
! 83: Order with array assignment:
! 84: in f()
! 85: in g()
! 86: array(1) {
! 87: [%u|b%"name"]=>
! 88: %string|unicode%(14) "assigned value"
! 89: }
! 90:
! 91:
! 92: Order with object property assignment:
! 93: in f()
! 94: in g()
! 95: object(stdClass)#%d (1) {
! 96: [%u|b%"assigned value"]=>
! 97: %string|unicode%(14) "assigned value"
! 98: }
! 99:
! 100:
! 101: Order with nested object property assignment:
! 102: in f()
! 103: in g()
! 104: object(stdClass)#%d (1) {
! 105: [%u|b%"o1"]=>
! 106: object(stdClass)#%d (1) {
! 107: [%u|b%"o2"]=>
! 108: object(stdClass)#%d (1) {
! 109: [%u|b%"assigned value"]=>
! 110: %string|unicode%(14) "assigned value"
! 111: }
! 112: }
! 113: }
! 114:
! 115:
! 116: Order with dim_list property assignment:
! 117: in f()
! 118: in g()
! 119: object(stdClass)#%d (1) {
! 120: [%u|b%"a"]=>
! 121: array(1) {
! 122: [%u|b%"assigned value"]=>
! 123: %string|unicode%(14) "assigned value"
! 124: }
! 125: }
! 126:
! 127:
! 128: Order with static property assignment:
! 129: in f()
! 130: in g()
! 131: %string|unicode%(14) "assigned value"
! 132:
! 133:
! 134: Order with static array property assignment:
! 135: in f()
! 136: in g()
! 137: array(1) {
! 138: [%u|b%"name"]=>
! 139: %string|unicode%(14) "assigned value"
! 140: }
! 141:
! 142:
! 143: Order with indexed string assignment:
! 144: in getOffset()
! 145: in newChar()
! 146: %string|unicode%(5) "jello"
! 147:
! 148:
! 149: Order with static string property assignment:
! 150: in getOffset()
! 151: in newChar()
! 152: %string|unicode%(5) "jello"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>