PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/slow/array_for_each/variable-variable-foreach.php

http://github.com/facebook/hiphop-php
PHP | 39 lines | 23 code | 11 blank | 5 comment | 0 complexity | 781396577e8b705778c03de3d2365677 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. ArrayForEachVariableVariableForeach::$rows=varray[1,2,3];
  3. function fn1() {
  4. $a="rows";
  5. $b="row";
  6. // TYPICAL FOREACH
  7. foreach(ArrayForEachVariableVariableForeach::$rows as ArrayForEachVariableVariableForeach::$row) {
  8. fn2();
  9. }
  10. // THE MALFORMED ARRAY
  11. foreach(ArrayForEachVariableVariableForeach::$rows as ArrayForEachVariableVariableForeach::$row) {
  12. fn2();
  13. }
  14. }
  15. function fn2() {
  16. $row = ArrayForEachVariableVariableForeach::$row;
  17. echo "row={$row}\n";
  18. }
  19. // ORIGINAL ARRAY
  20. print_r(ArrayForEachVariableVariableForeach::$rows);
  21. // SOME ITERATIONS
  22. fn1();
  23. // THE MALFORMED ARRAY
  24. print_r(ArrayForEachVariableVariableForeach::$rows);
  25. abstract final class ArrayForEachVariableVariableForeach {
  26. public static $rows;
  27. public static $row;
  28. }