PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.9.16
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.9.16
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / phpfastcache / phpfastcache / lib / Phpfastcache / Util / ArrayObject.php

ArrayObject.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.9.16, at vendor_prefixed/phpfastcache/phpfastcache/lib/Phpfastcache/Util/ArrayObject.php

148 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 *
5 * This file is part of phpFastCache.
6 *
7 * @license MIT License (MIT)
8 *
9 * For full copyright and license information, please see the docs/CREDITS.txt file.
10 *
11 * @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> https://www.phpfastcache.com
12 * @author Georges.L (Geolim4) <contact@geolim4.com>
13 *
14 */
15 declare (strict_types=1);
16 namespace WCPOS\Vendor\Phpfastcache\Util;
17
18 use ArrayAccess;
19 use Countable;
20 use Iterator;
21 /**
22 * Class ArrayObject
23 * @package phpFastCache\Util
24 */
25 class ArrayObject implements ArrayAccess, Iterator, Countable
26 {
27 /**
28 * @var array
29 */
30 private $array;
31 /**
32 * @var int
33 */
34 private $position = 0;
35 /**
36 * @param $args
37 * ArrayObject constructor.
38 */
39 public function __construct(...$args)
40 {
41 $this->array = \count($args) === 1 && \is_array($args[0]) ? $args[0] : $args;
42 }
43 /**
44 * @return mixed
45 */
46 #[\ReturnTypeWillChange]
47 public function current()
48 {
49 return $this->array[$this->position];
50 }
51 /**
52 *
53 */
54 public function next() : void
55 {
56 ++$this->position;
57 }
58 /**
59 * @return int
60 */
61 public function key() : int
62 {
63 return $this->position;
64 }
65 /**
66 * @return bool
67 */
68 public function valid() : bool
69 {
70 return $this->offsetExists($this->position);
71 }
72 /**
73 * @param mixed $offset
74 * @return bool
75 */
76 public function offsetExists($offset) : bool
77 {
78 return \array_key_exists($offset, $this->array);
79 }
80 /**
81 *
82 */
83 public function rewind() : void
84 {
85 $this->position = 0;
86 }
87 /**
88 * @return int
89 */
90 public function count() : int
91 {
92 return \count($this->array);
93 }
94 /**
95 * @param mixed $offset
96 * @return mixed
97 */
98 #[\ReturnTypeWillChange]
99 public function offsetGet($offset)
100 {
101 return $this->array[$offset] ?? null;
102 }
103 /**
104 * @param mixed $offset
105 * @param mixed $value
106 */
107 public function offsetSet($offset, $value) : void
108 {
109 // NOTE: THIS IS THE FIX FOR THE ISSUE "Indirect modification of overloaded element of SplFixedArray has no effect"
110 // NOTE: WHEN APPENDING AN ARRAY (E.G. myArr[] = 5) THE KEY IS NULL, SO WE TEST FOR THIS CONDITION BELOW, AND VOILA
111 if ($offset === null) {
112 $this->array[] = $value;
113 } else {
114 $this->array[$offset] = $value;
115 }
116 }
117 /**
118 * @param mixed $offset
119 */
120 public function offsetUnset($offset) : void
121 {
122 unset($this->array[$offset]);
123 }
124 /**
125 * @return array
126 */
127 public function toArray() : array
128 {
129 return $this->array;
130 }
131 /**
132 * @param array $array
133 * @return self
134 */
135 public function mergeArray(array $array) : self
136 {
137 $this->array = \array_merge($this->array, $array);
138 return $this;
139 }
140 /**
141 * @return array
142 */
143 protected function &getArray() : array
144 {
145 return $this->array;
146 }
147 }
148