@@ 61-73 (lines=13) @@ | ||
58 | return array_keys($value) != range(0, count($value) - 1); |
|
59 | } |
|
60 | ||
61 | private function wrapAsArray(Isolate $isolate, Context $context, array $value): ArrayObject |
|
62 | { |
|
63 | $ret = new ArrayObject($context); |
|
64 | // TODO: write test to ensure items have the same order, sort() was breaking that order |
|
65 | $key = 0; |
|
66 | foreach ($value as $val) { |
|
67 | $js_val = $this->wrapper->wrap($isolate, $context, $val); |
|
68 | $js_key = new IntegerValue($isolate, $key++); |
|
69 | $ret->set($context, $js_key, $js_val); |
|
70 | } |
|
71 | ||
72 | return $ret; |
|
73 | } |
|
74 | ||
75 | private function wrapAsObject(Isolate $isolate, Context $context, array $value): ObjectValue |
|
76 | { |
|
@@ 75-86 (lines=12) @@ | ||
72 | return $ret; |
|
73 | } |
|
74 | ||
75 | private function wrapAsObject(Isolate $isolate, Context $context, array $value): ObjectValue |
|
76 | { |
|
77 | $ret = new ObjectValue($context); |
|
78 | ||
79 | foreach ($value as $key => $val) { |
|
80 | $js_val = $this->wrapper->wrap($isolate, $context, $val); |
|
81 | $js_key = $this->wrapper->wrap($isolate, $context, $key); |
|
82 | $ret->set($context, $js_key, $js_val); |
|
83 | } |
|
84 | ||
85 | return $ret; |
|
86 | } |
|
87 | } |
|
88 |