array_003.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. SPL: ArrayObject from object
  3. --FILE--
  4. <?php
  5. // This test also needs to exclude the protected and private variables
  6. // since they cannot be accessed from the external object which iterates
  7. // them.
  8. class test
  9. {
  10. public $pub = "public";
  11. protected $pro = "protected";
  12. private $pri = "private";
  13. function __construct()
  14. {
  15. $this->imp = "implicit";
  16. }
  17. };
  18. $test = new test;
  19. $test->dyn = "dynamic";
  20. print_r($test);
  21. $object = new ArrayObject($test);
  22. print_r($object);
  23. foreach($test as $key => $val)
  24. {
  25. echo "$key => $val\n";
  26. }
  27. ?>
  28. ===DONE===
  29. <?php exit(0); ?>
  30. --EXPECTF--
  31. test Object
  32. (
  33. [pub] => public
  34. [pro:protected] => protected
  35. [pri:test:private] => private
  36. [imp] => implicit
  37. [dyn] => dynamic
  38. )
  39. ArrayObject Object
  40. (
  41. [storage:ArrayObject:private] => test Object
  42. (
  43. [pub] => public
  44. [pro:protected] => protected
  45. [pri:test:private] => private
  46. [imp] => implicit
  47. [dyn] => dynamic
  48. )
  49. )
  50. pub => public
  51. imp => implicit
  52. dyn => dynamic
  53. ===DONE===