You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.1 KiB

  1. --TEST--
  2. SPL: FixedArray: std operations
  3. --INI--
  4. allow_call_time_pass_reference=1
  5. --FILE--
  6. <?php
  7. $a = new SplFixedArray(0);
  8. // errors
  9. try {
  10. $a[0] = "value1";
  11. } catch (RuntimeException $e) {
  12. echo "Exception: ".$e->getMessage()."\n";
  13. }
  14. try {
  15. var_dump($a["asdf"]);
  16. } catch (RuntimeException $e) {
  17. echo "Exception: ".$e->getMessage()."\n";
  18. }
  19. try {
  20. unset($a[-1]);
  21. } catch (RuntimeException $e) {
  22. echo "Exception: ".$e->getMessage()."\n";
  23. }
  24. $a->setSize(10);
  25. $a[0] = "value0";
  26. $a[1] = "value1";
  27. $a[2] = "value2";
  28. $a[3] = "value3";
  29. $ref = "value4";
  30. $ref2 =&$ref;
  31. $a[4] = $ref;
  32. $ref = "value5";
  33. unset($a[1]);
  34. var_dump($a[0], $a[2], $a[3], $a[4]);
  35. // countable
  36. var_dump(count($a), $a->getSize(), count($a) == $a->getSize());
  37. // clonable
  38. $b = clone $a;
  39. $a[0] = "valueNew";
  40. var_dump($b[0]);
  41. ?>
  42. ===DONE===
  43. --EXPECTF--
  44. Exception: Index invalid or out of range
  45. Exception: Index invalid or out of range
  46. Exception: Index invalid or out of range
  47. string(6) "value0"
  48. string(6) "value2"
  49. string(6) "value3"
  50. string(6) "value4"
  51. int(10)
  52. int(10)
  53. bool(true)
  54. string(6) "value0"
  55. ===DONE===