basic.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. abc1
  2. -----
  3. <?php
  4. echo
  5. 1
  6. +
  7. 2
  8. +
  9. 3;
  10. -----
  11. $stmts[0]->exprs[0]->left->right->value = 42;
  12. -----
  13. <?php
  14. echo
  15. 1
  16. +
  17. 42
  18. +
  19. 3;
  20. -----
  21. <?php
  22. function foo($a)
  23. { return $a; }
  24. -----
  25. $stmts[0]->name = new Node\Identifier('bar');
  26. -----
  27. <?php
  28. function bar($a)
  29. { return $a; }
  30. -----
  31. <?php
  32. function
  33. foo() {
  34. call(
  35. $bar
  36. );
  37. }
  38. -----
  39. // This triggers a fallback
  40. $stmts[0]->byRef = true;
  41. -----
  42. <?php
  43. function &foo()
  44. {
  45. call(
  46. $bar
  47. );
  48. }
  49. -----
  50. <?php
  51. function
  52. foo() {
  53. echo "Start
  54. End";
  55. }
  56. -----
  57. // This triggers a fallback
  58. $stmts[0]->byRef = true;
  59. -----
  60. <?php
  61. function &foo()
  62. {
  63. echo "Start
  64. End";
  65. }
  66. -----
  67. <?php
  68. function test() {
  69. call1(
  70. $bar
  71. );
  72. }
  73. call2(
  74. $foo
  75. );
  76. -----
  77. $tmp = $stmts[0]->stmts[0];
  78. $stmts[0]->stmts[0] = $stmts[1];
  79. $stmts[1] = $tmp;
  80. -----
  81. <?php
  82. function test() {
  83. call2(
  84. $foo
  85. );
  86. }
  87. call1(
  88. $bar
  89. );
  90. -----
  91. <?php
  92. x;
  93. function test() {
  94. call1(
  95. $bar
  96. );
  97. }
  98. call2(
  99. $foo
  100. );
  101. -----
  102. $tmp = $stmts[1]->stmts[0];
  103. $stmts[1]->stmts[0] = $stmts[2];
  104. $stmts[2] = $tmp;
  105. // Same test, but also removing first statement, triggering fallback
  106. array_splice($stmts, 0, 1, []);
  107. -----
  108. <?php
  109. function test() {
  110. call2(
  111. $foo
  112. );
  113. }
  114. call1(
  115. $bar
  116. );
  117. -----
  118. <?php
  119. echo 1;
  120. -----
  121. $stmts[0] = new Stmt\Expression(
  122. new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')));
  123. -----
  124. <?php
  125. $a = $b;
  126. -----
  127. <?php
  128. echo$a;
  129. -----
  130. $stmts[0]->exprs[0] = new Expr\ConstFetch(new Node\Name('C'));
  131. -----
  132. <?php
  133. echo C;
  134. -----
  135. <?php
  136. function foo() {
  137. foo();
  138. /*
  139. * bar
  140. */
  141. baz();
  142. }
  143. {
  144. $x;
  145. }
  146. -----
  147. $tmp = $stmts[0];
  148. $stmts[0] = $stmts[1];
  149. $stmts[1] = $tmp;
  150. /* TODO This used to do two replacement operations, but with the node list diffing this is a
  151. * remove, keep, add (which probably makes more sense). As such, this currently triggers a
  152. * fallback. */
  153. -----
  154. <?php
  155. $x;
  156. function foo() {
  157. foo();
  158. /*
  159. * bar
  160. */
  161. baz();
  162. }
  163. -----
  164. <?php
  165. echo "${foo}bar";
  166. echo "${foo['baz']}bar";
  167. -----
  168. $stmts[0]->exprs[0]->parts[0] = new Expr\Variable('bar');
  169. $stmts[1]->exprs[0]->parts[0] = new Expr\Variable('bar');
  170. -----
  171. <?php
  172. echo "{$bar}bar";
  173. echo "{$bar}bar";
  174. -----
  175. <?php
  176. [$a
  177. ,$b
  178. ,
  179. ,] = $b;
  180. -----
  181. /* Nothing */
  182. -----
  183. <?php
  184. [$a
  185. ,$b
  186. ,
  187. ,] = $b;