PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/spec/tests/classes/__php_incomplete_class.php

http://github.com/facebook/hiphop-php
PHP | 48 lines | 30 code | 12 blank | 6 comment | 0 complexity | 4f5f4a7732d83c07a9153aa3a11248f9 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. /*
  3. +-------------------------------------------------------------+
  4. | Copyright (c) 2015 Facebook, Inc. (http://www.facebook.com) |
  5. +-------------------------------------------------------------+
  6. */
  7. error_reporting(-1);
  8. class Point
  9. {
  10. private $x;
  11. private $y;
  12. public function __construct($x = 0, $y = 0)
  13. {
  14. $this->x = $x;
  15. $this->y = $y;
  16. echo "\nInside " . __METHOD__ . ", $this\n\n";
  17. }
  18. public function __toString()
  19. {
  20. return '(' . $this->x . ',' . $this->y . ')';
  21. }
  22. }
  23. echo "---------------- create, serialize, and unserialize a Point -------------------\n";
  24. $p = new Point(2, 5);
  25. echo "Point \$p = $p\n";
  26. $s = serialize($p); // all instance properties get serialized
  27. var_dump($s);
  28. echo "------\n";
  29. $v = unserialize($s); // without a __wakeup method, any instance property present
  30. // in the string takes on its default value.
  31. var_dump($v);
  32. $s[5] = 'J'; // change class name, so a unserialize failure occurs
  33. var_dump($s);
  34. $v = unserialize($s);
  35. var_dump($v);
  36. print_r($v);