@@ -10,26 +10,28 @@ abstract class AbstractStructArrayBase extends AbstractStructBase implements Str
1010 * Array that contains values when only one parameter is set when calling __construct method
1111 * @var array
1212 */
13- protected array $ internArray = [];
13+ private array $ internArray = [];
1414
1515 /**
1616 * Bool that tells if array is set or not
1717 * @var bool
1818 */
19- protected bool $ internArrayIsArray = false ;
19+ private bool $ internArrayIsArray = false ;
2020
2121 /**
2222 * Items index browser
2323 * @var int
2424 */
25- protected int $ internArrayOffset = 0 ;
25+ private int $ internArrayOffset = 0 ;
2626
2727 /**
2828 * Method alias to count
2929 * @return int
3030 */
3131 public function length (): int
3232 {
33+ $ this ->initInternArray ();
34+
3335 return $ this ->count ();
3436 }
3537
@@ -39,6 +41,8 @@ public function length(): int
3941 */
4042 public function count (): int
4143 {
44+ $ this ->initInternArray ();
45+
4246 return $ this ->getInternArrayIsArray () ? count ($ this ->getInternArray ()) : -1 ;
4347 }
4448
@@ -48,6 +52,8 @@ public function count(): int
4852 */
4953 public function current ()
5054 {
55+ $ this ->initInternArray ();
56+
5157 return $ this ->offsetGet ($ this ->internArrayOffset );
5258 }
5359
@@ -57,6 +63,8 @@ public function current()
5763 */
5864 public function next (): self
5965 {
66+ $ this ->initInternArray ();
67+
6068 return $ this ->setInternArrayOffset ($ this ->getInternArrayOffset () + 1 );
6169 }
6270
@@ -66,6 +74,8 @@ public function next(): self
6674 */
6775 public function rewind (): self
6876 {
77+ $ this ->initInternArray ();
78+
6979 return $ this ->setInternArrayOffset (0 );
7080 }
7181
@@ -75,6 +85,8 @@ public function rewind(): self
7585 */
7686 public function valid (): bool
7787 {
88+ $ this ->initInternArray ();
89+
7890 return $ this ->offsetExists ($ this ->getInternArrayOffset ());
7991 }
8092
@@ -84,6 +96,8 @@ public function valid(): bool
8496 */
8597 public function key (): int
8698 {
99+ $ this ->initInternArray ();
100+
87101 return $ this ->getInternArrayOffset ();
88102 }
89103
@@ -94,6 +108,8 @@ public function key(): int
94108 */
95109 public function item ($ index )
96110 {
111+ $ this ->initInternArray ();
112+
97113 return $ this ->offsetGet ($ index );
98114 }
99115
@@ -127,6 +143,8 @@ public function add($item): self
127143 */
128144 public function first ()
129145 {
146+ $ this ->initInternArray ();
147+
130148 return $ this ->item (0 );
131149 }
132150
@@ -136,6 +154,8 @@ public function first()
136154 */
137155 public function last ()
138156 {
157+ $ this ->initInternArray ();
158+
139159 return $ this ->item ($ this ->length () - 1 );
140160 }
141161
@@ -146,6 +166,8 @@ public function last()
146166 */
147167 public function offsetExists ($ offset ): bool
148168 {
169+ $ this ->initInternArray ();
170+
149171 return ($ this ->getInternArrayIsArray () && array_key_exists ($ offset , $ this ->getInternArray ()));
150172 }
151173
@@ -156,6 +178,8 @@ public function offsetExists($offset): bool
156178 */
157179 public function offsetGet ($ offset )
158180 {
181+ $ this ->initInternArray ();
182+
159183 return $ this ->offsetExists ($ offset ) ? $ this ->internArray [$ offset ] : null ;
160184 }
161185
@@ -167,6 +191,8 @@ public function offsetGet($offset)
167191 */
168192 public function offsetSet ($ offset , $ value ): self
169193 {
194+ $ this ->initInternArray ();
195+
170196 $ this ->internArray [$ offset ] = $ value ;
171197
172198 return $ this ->setPropertyValue ($ this ->getAttributeName (), $ this ->internArray );
@@ -179,6 +205,8 @@ public function offsetSet($offset, $value): self
179205 */
180206 public function offsetUnset ($ offset ): self
181207 {
208+ $ this ->initInternArray ();
209+
182210 if ($ this ->offsetExists ($ offset )) {
183211 unset($ this ->internArray [$ offset ]);
184212 $ this ->setPropertyValue ($ this ->getAttributeName (), $ this ->internArray );
@@ -191,7 +219,7 @@ public function offsetUnset($offset): self
191219 * Method returning intern array to iterate trough
192220 * @return array
193221 */
194- public function getInternArray (): array
222+ private function getInternArray (): array
195223 {
196224 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
197225
@@ -203,7 +231,7 @@ public function getInternArray(): array
203231 * @param array $internArray
204232 * @return AbstractStructArrayBase
205233 */
206- public function setInternArray (array $ internArray ): self
234+ private function setInternArray (array $ internArray ): self
207235 {
208236 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
209237
@@ -216,7 +244,7 @@ public function setInternArray(array $internArray): self
216244 * Method returns intern array index when iterating trough
217245 * @return int
218246 */
219- public function getInternArrayOffset (): int
247+ private function getInternArrayOffset (): int
220248 {
221249 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
222250
@@ -229,7 +257,7 @@ public function getInternArrayOffset(): int
229257 * @param bool $internCall indicates that methods is calling itself
230258 * @return AbstractStructArrayBase
231259 */
232- public function initInternArray (array $ array = [], bool $ internCall = false ): self
260+ private function initInternArray (array $ array = [], bool $ internCall = false ): self
233261 {
234262 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
235263
@@ -238,7 +266,7 @@ public function initInternArray(array $array = [], bool $internCall = false): se
238266 ->setInternArray ($ array )
239267 ->setInternArrayOffset (0 )
240268 ->setInternArrayIsArray (true );
241- } elseif (!$ internCall && property_exists ($ this , $ this ->getAttributeName ())) {
269+ } elseif (!$ this -> internArrayIsArray && ! $ internCall && property_exists ($ this , $ this ->getAttributeName ())) {
242270 $ this ->initInternArray ($ this ->getPropertyValue ($ this ->getAttributeName ()), true );
243271 }
244272
@@ -250,7 +278,7 @@ public function initInternArray(array $array = [], bool $internCall = false): se
250278 * @param int $internArrayOffset
251279 * @return AbstractStructArrayBase
252280 */
253- public function setInternArrayOffset (int $ internArrayOffset ): self
281+ private function setInternArrayOffset (int $ internArrayOffset ): self
254282 {
255283 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
256284
@@ -263,7 +291,7 @@ public function setInternArrayOffset(int $internArrayOffset): self
263291 * Method returning true if intern array is an actual array
264292 * @return bool
265293 */
266- public function getInternArrayIsArray (): bool
294+ private function getInternArrayIsArray (): bool
267295 {
268296 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
269297
@@ -275,7 +303,7 @@ public function getInternArrayIsArray(): bool
275303 * @param bool $internArrayIsArray
276304 * @return AbstractStructArrayBase
277305 */
278- public function setInternArrayIsArray (bool $ internArrayIsArray = false ): self
306+ private function setInternArrayIsArray (bool $ internArrayIsArray = false ): self
279307 {
280308 @trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
281309
0 commit comments