array_access_008.phpt 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test V8::executeString() : in array (isset) behaviour of ArrayAccess
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --INI--
  6. v8js.use_array_access = 1
  7. --FILE--
  8. <?php
  9. class MyArray implements ArrayAccess, Countable {
  10. private $data = Array('one', null, 'three');
  11. public function offsetExists($offset) {
  12. return isset($this->data[$offset]);
  13. }
  14. public function offsetGet($offset) {
  15. return $this->data[$offset];
  16. }
  17. public function offsetSet($offset, $value) {
  18. $this->data[$offset] = $value;
  19. }
  20. public function offsetUnset($offset) {
  21. unset($this->data[$offset]);
  22. }
  23. public function count() {
  24. return max(array_keys($this->data)) + 1;
  25. }
  26. }
  27. $v8 = new V8Js();
  28. $v8->myarr = new MyArray();
  29. $js = <<<EOF
  30. var jsarr = [ "one", , "three" ];
  31. var_dump(0 in jsarr);
  32. var_dump(1 in jsarr);
  33. var_dump(0 in PHP.myarr);
  34. var_dump(1 in PHP.myarr);
  35. EOF;
  36. $v8->executeString($js);
  37. ?>
  38. ===EOF===
  39. --EXPECT--
  40. bool(true)
  41. bool(false)
  42. bool(true)
  43. bool(false)
  44. ===EOF===