-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecation fixes for PHP 8 #298
Conversation
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: vgrem#293
Greetings, Thank you for those improvements! 👍 Regarding
not a slightest chance to keep it still compatible with Seems this particular change breaks the backward compatibility with version |
The whole commit "Return types in ClientObjectCollection" would need to be adjusted so that no return types are introduced at all. The "supported PHP versions" list at https://www.php.net/supported-versions.php says that support for PHP 7.1 ended 2019. I don't think that there is any reason to keep support for 5.x, which was end-of-life'd in 2018. But that's up to you to decide. |
There are stats for PHP versions that install your package: https://packagist.org/packages/vgrem/php-spo/php-stats PHP 5.5 and earlier are at 0.0%, PHP 5.6 is 0.6%, PHP 7.0 at 0.1%. |
That's a valuable piece of stats, thank you! A new version is expected to be released later today, once |
The library itself works with PHP8, but deprecation notices are thrown.
The commits here get rid of those while keeping compatibility with PHP 7.1+ (compat with PHP 5 is not possible anymore).
Related: #293