Commit a1d7ae3
committed
Fix deprecation: Return types in ClientObjectCollection
PHP 8.1 logs deprecation warnings:
> Return type of Office365\Runtime\ClientObjectCollection::getIterator()
> should either be compatible with IteratorAggregate::getIterator(): Traversable,
> or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress
> the notice in vendor/vgrem/php-spo/src/Runtime/ClientObjectCollection.php on line 287
and
> Return type of Office365\Runtime\ClientObjectCollection::offsetExists($offset)
> should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool
and
> Return type of Office365\Runtime\ClientObjectCollection::offsetGet($offset)
> should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed,
> or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
and
> Return type of Office365\Runtime\ClientObjectCollection::offsetSet($offset, $value)
> should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void
and
> Return type of Office365\Runtime\ClientObjectCollection::offsetUnset($offset)
> should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void
Those can be fixed by adding return types for getIterator(), offsetExists(),
offsetSet() and offsetUnset().
For those, the minimum required PHP version needs to be raised to PHP 7.1,
since the "void" return type only exists in there.
The return type for offsetGet() is "mixed", which cannot be expressed in PHP 7.x,
only PHP 8.0 and later.
I decided to use the "#[\ReturnTypeWillChange]" annotation so the lib
can stay compatible with PHP 7.
Related: #2931 parent 1a16d48 commit a1d7ae3
2 files changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
351 | | - | |
| 352 | + | |
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
367 | | - | |
| 368 | + | |
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
| |||
0 commit comments