@@ -10,26 +10,28 @@ abstract class AbstractStructArrayBase extends AbstractStructBase implements Str
10
10
* Array that contains values when only one parameter is set when calling __construct method
11
11
* @var array
12
12
*/
13
- protected array $ internArray = [];
13
+ private array $ internArray = [];
14
14
15
15
/**
16
16
* Bool that tells if array is set or not
17
17
* @var bool
18
18
*/
19
- protected bool $ internArrayIsArray = false ;
19
+ private bool $ internArrayIsArray = false ;
20
20
21
21
/**
22
22
* Items index browser
23
23
* @var int
24
24
*/
25
- protected int $ internArrayOffset = 0 ;
25
+ private int $ internArrayOffset = 0 ;
26
26
27
27
/**
28
28
* Method alias to count
29
29
* @return int
30
30
*/
31
31
public function length (): int
32
32
{
33
+ $ this ->initInternArray ();
34
+
33
35
return $ this ->count ();
34
36
}
35
37
@@ -39,6 +41,8 @@ public function length(): int
39
41
*/
40
42
public function count (): int
41
43
{
44
+ $ this ->initInternArray ();
45
+
42
46
return $ this ->getInternArrayIsArray () ? count ($ this ->getInternArray ()) : -1 ;
43
47
}
44
48
@@ -48,6 +52,8 @@ public function count(): int
48
52
*/
49
53
public function current ()
50
54
{
55
+ $ this ->initInternArray ();
56
+
51
57
return $ this ->offsetGet ($ this ->internArrayOffset );
52
58
}
53
59
@@ -57,6 +63,8 @@ public function current()
57
63
*/
58
64
public function next (): self
59
65
{
66
+ $ this ->initInternArray ();
67
+
60
68
return $ this ->setInternArrayOffset ($ this ->getInternArrayOffset () + 1 );
61
69
}
62
70
@@ -66,6 +74,8 @@ public function next(): self
66
74
*/
67
75
public function rewind (): self
68
76
{
77
+ $ this ->initInternArray ();
78
+
69
79
return $ this ->setInternArrayOffset (0 );
70
80
}
71
81
@@ -75,6 +85,8 @@ public function rewind(): self
75
85
*/
76
86
public function valid (): bool
77
87
{
88
+ $ this ->initInternArray ();
89
+
78
90
return $ this ->offsetExists ($ this ->getInternArrayOffset ());
79
91
}
80
92
@@ -84,6 +96,8 @@ public function valid(): bool
84
96
*/
85
97
public function key (): int
86
98
{
99
+ $ this ->initInternArray ();
100
+
87
101
return $ this ->getInternArrayOffset ();
88
102
}
89
103
@@ -94,6 +108,8 @@ public function key(): int
94
108
*/
95
109
public function item ($ index )
96
110
{
111
+ $ this ->initInternArray ();
112
+
97
113
return $ this ->offsetGet ($ index );
98
114
}
99
115
@@ -127,6 +143,8 @@ public function add($item): self
127
143
*/
128
144
public function first ()
129
145
{
146
+ $ this ->initInternArray ();
147
+
130
148
return $ this ->item (0 );
131
149
}
132
150
@@ -136,6 +154,8 @@ public function first()
136
154
*/
137
155
public function last ()
138
156
{
157
+ $ this ->initInternArray ();
158
+
139
159
return $ this ->item ($ this ->length () - 1 );
140
160
}
141
161
@@ -146,6 +166,8 @@ public function last()
146
166
*/
147
167
public function offsetExists ($ offset ): bool
148
168
{
169
+ $ this ->initInternArray ();
170
+
149
171
return ($ this ->getInternArrayIsArray () && array_key_exists ($ offset , $ this ->getInternArray ()));
150
172
}
151
173
@@ -156,6 +178,8 @@ public function offsetExists($offset): bool
156
178
*/
157
179
public function offsetGet ($ offset )
158
180
{
181
+ $ this ->initInternArray ();
182
+
159
183
return $ this ->offsetExists ($ offset ) ? $ this ->internArray [$ offset ] : null ;
160
184
}
161
185
@@ -167,6 +191,8 @@ public function offsetGet($offset)
167
191
*/
168
192
public function offsetSet ($ offset , $ value ): self
169
193
{
194
+ $ this ->initInternArray ();
195
+
170
196
$ this ->internArray [$ offset ] = $ value ;
171
197
172
198
return $ this ->setPropertyValue ($ this ->getAttributeName (), $ this ->internArray );
@@ -179,6 +205,8 @@ public function offsetSet($offset, $value): self
179
205
*/
180
206
public function offsetUnset ($ offset ): self
181
207
{
208
+ $ this ->initInternArray ();
209
+
182
210
if ($ this ->offsetExists ($ offset )) {
183
211
unset($ this ->internArray [$ offset ]);
184
212
$ this ->setPropertyValue ($ this ->getAttributeName (), $ this ->internArray );
@@ -191,7 +219,7 @@ public function offsetUnset($offset): self
191
219
* Method returning intern array to iterate trough
192
220
* @return array
193
221
*/
194
- public function getInternArray (): array
222
+ private function getInternArray (): array
195
223
{
196
224
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
197
225
@@ -203,7 +231,7 @@ public function getInternArray(): array
203
231
* @param array $internArray
204
232
* @return AbstractStructArrayBase
205
233
*/
206
- public function setInternArray (array $ internArray ): self
234
+ private function setInternArray (array $ internArray ): self
207
235
{
208
236
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
209
237
@@ -216,7 +244,7 @@ public function setInternArray(array $internArray): self
216
244
* Method returns intern array index when iterating trough
217
245
* @return int
218
246
*/
219
- public function getInternArrayOffset (): int
247
+ private function getInternArrayOffset (): int
220
248
{
221
249
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
222
250
@@ -229,7 +257,7 @@ public function getInternArrayOffset(): int
229
257
* @param bool $internCall indicates that methods is calling itself
230
258
* @return AbstractStructArrayBase
231
259
*/
232
- public function initInternArray (array $ array = [], bool $ internCall = false ): self
260
+ private function initInternArray (array $ array = [], bool $ internCall = false ): self
233
261
{
234
262
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
235
263
@@ -238,7 +266,7 @@ public function initInternArray(array $array = [], bool $internCall = false): se
238
266
->setInternArray ($ array )
239
267
->setInternArrayOffset (0 )
240
268
->setInternArrayIsArray (true );
241
- } elseif (!$ internCall && property_exists ($ this , $ this ->getAttributeName ())) {
269
+ } elseif (!$ this -> internArrayIsArray && ! $ internCall && property_exists ($ this , $ this ->getAttributeName ())) {
242
270
$ this ->initInternArray ($ this ->getPropertyValue ($ this ->getAttributeName ()), true );
243
271
}
244
272
@@ -250,7 +278,7 @@ public function initInternArray(array $array = [], bool $internCall = false): se
250
278
* @param int $internArrayOffset
251
279
* @return AbstractStructArrayBase
252
280
*/
253
- public function setInternArrayOffset (int $ internArrayOffset ): self
281
+ private function setInternArrayOffset (int $ internArrayOffset ): self
254
282
{
255
283
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
256
284
@@ -263,7 +291,7 @@ public function setInternArrayOffset(int $internArrayOffset): self
263
291
* Method returning true if intern array is an actual array
264
292
* @return bool
265
293
*/
266
- public function getInternArrayIsArray (): bool
294
+ private function getInternArrayIsArray (): bool
267
295
{
268
296
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
269
297
@@ -275,7 +303,7 @@ public function getInternArrayIsArray(): bool
275
303
* @param bool $internArrayIsArray
276
304
* @return AbstractStructArrayBase
277
305
*/
278
- public function setInternArrayIsArray (bool $ internArrayIsArray = false ): self
306
+ private function setInternArrayIsArray (bool $ internArrayIsArray = false ): self
279
307
{
280
308
@trigger_error (sprintf ('%s() will be private in WsdlToPhp/PackageBase 5.0. ' , __METHOD__ ), E_USER_DEPRECATED );
281
309
0 commit comments