PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/quick/recursive-unset.php

http://github.com/facebook/hiphop-php
PHP | 57 lines | 45 code | 9 blank | 3 comment | 5 complexity | 900b4d47be6f37f613543e718e0bf22d 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. <?php
  2. error_reporting(-1);
  3. //////////////////////////////////////////////////////////////////////
  4. class Foo {
  5. public function __unset($name) {
  6. var_dump($name);
  7. if ($name != 'bar') unset($this->bar);
  8. }
  9. }
  10. function main1() {
  11. $f = new Foo;
  12. unset($f->foo);
  13. }
  14. //////////////////////////////////////////////////////////////////////
  15. class Foo2 {
  16. public function __unset($name) {
  17. var_dump($name);
  18. unset($this->foo);
  19. }
  20. }
  21. function main2() {
  22. $f = new Foo2;
  23. unset($f->bar);
  24. }
  25. //////////////////////////////////////////////////////////////////////
  26. class CaseFoo {
  27. public function __unset($name) {
  28. var_dump($name);
  29. if ($name === 'bar') { unset($this->Bar); return; }
  30. if ($name === 'Bar') { unset($this->foo); return; }
  31. if ($name === 'foo') { unset($this->bar); return; }
  32. var_dump("shouldn't get here");
  33. }
  34. }
  35. function main3() {
  36. $f = new CaseFoo;
  37. unset($f->bar);
  38. }
  39. //////////////////////////////////////////////////////////////////////
  40. main1();
  41. echo "--\n";
  42. main2();
  43. echo "--\n";
  44. main3();
  45. echo "--\n";