2020 */
2121class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable
2222{
23- /**
24- * This is to allow for reset() to work properly.
25- *
26- * WARNING! This MUST be the first variable in this class!!!
27- *
28- * PHPStan is ignoring this because we don't need actually to read the property
29- *
30- * @var mixed
31- * @phpstan-ignore-next-line
32- */
33- private $ first_property = null ;
34-
3523 /**
3624 * Collection data.
3725 *
@@ -47,7 +35,6 @@ class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable
4735 public function __construct (array $ data = [])
4836 {
4937 $ this ->data = $ data ;
50- $ this ->handleReset ();
5138 }
5239
5340 /**
@@ -68,7 +55,6 @@ public function __get(string $key)
6855 public function __set (string $ key , $ value ): void
6956 {
7057 $ this ->data [$ key ] = $ value ;
71- $ this ->handleReset ();
7258 }
7359
7460 /**
@@ -85,7 +71,6 @@ public function __isset(string $key): bool
8571 public function __unset (string $ key ): void
8672 {
8773 unset($ this ->data [$ key ]);
88- $ this ->handleReset ();
8974 }
9075
9176 /**
@@ -115,7 +100,6 @@ public function offsetSet($offset, $value): void
115100 } else {
116101 $ this ->data [$ offset ] = $ value ;
117102 }
118- $ this ->handleReset ();
119103 }
120104
121105 /**
@@ -136,17 +120,6 @@ public function offsetExists($offset): bool
136120 public function offsetUnset ($ offset ): void
137121 {
138122 unset($ this ->data [$ offset ]);
139- $ this ->handleReset ();
140- }
141-
142- /**
143- * This is to allow for reset() of a Collection to work properly.
144- *
145- * @return void
146- */
147- public function handleReset ()
148- {
149- $ this ->first_property = reset ($ this ->data );
150123 }
151124
152125 /**
@@ -234,7 +207,6 @@ public function getData(): array
234207 public function setData (array $ data ): void
235208 {
236209 $ this ->data = $ data ;
237- $ this ->handleReset ();
238210 }
239211
240212 #[\ReturnTypeWillChange]
0 commit comments