bug31683.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. --TEST--
  2. Bug #31683 (changes to $name in __get($name) override future parameters)
  3. --FILE--
  4. <?php
  5. class Foo implements ArrayAccess {
  6. function __get($test) {
  7. var_dump($test);
  8. $test = 'bug';
  9. }
  10. function __set($test, $val) {
  11. var_dump($test);
  12. var_dump($val);
  13. $test = 'bug';
  14. $val = 'bug';
  15. }
  16. function __call($test, $arg) {
  17. var_dump($test);
  18. $test = 'bug';
  19. }
  20. function offsetget($test) {
  21. var_dump($test);
  22. $test = 'bug';
  23. return 123;
  24. }
  25. function offsetset($test, $val) {
  26. var_dump($test);
  27. var_dump($val);
  28. $test = 'bug';
  29. $val = 'bug';
  30. }
  31. function offsetexists($test) {
  32. var_dump($test);
  33. $test = 'bug';
  34. }
  35. function offsetunset($test) {
  36. var_dump($test);
  37. $test = 'bug';
  38. }
  39. }
  40. $foo = new Foo();
  41. $a = "ok";
  42. for ($i=0; $i < 2; $i++) {
  43. $foo->ok("ok");
  44. $foo->ok;
  45. $foo->ok = "ok";
  46. $x = $foo["ok"];
  47. $foo["ok"] = "ok";
  48. isset($foo["ok"]);
  49. unset($foo["ok"]);
  50. // $foo[];
  51. $foo[] = "ok";
  52. // isset($foo[]);
  53. // unset($foo[]);
  54. $foo->$a;
  55. echo "---\n";
  56. }
  57. ?>
  58. --EXPECT--
  59. string(2) "ok"
  60. string(2) "ok"
  61. string(2) "ok"
  62. string(2) "ok"
  63. string(2) "ok"
  64. string(2) "ok"
  65. string(2) "ok"
  66. string(2) "ok"
  67. string(2) "ok"
  68. NULL
  69. string(2) "ok"
  70. string(2) "ok"
  71. ---
  72. string(2) "ok"
  73. string(2) "ok"
  74. string(2) "ok"
  75. string(2) "ok"
  76. string(2) "ok"
  77. string(2) "ok"
  78. string(2) "ok"
  79. string(2) "ok"
  80. string(2) "ok"
  81. NULL
  82. string(2) "ok"
  83. string(2) "ok"
  84. ---