oooas
oooas copied to clipboard
Add return typehints to Extensions ArrayAccess
Fix for https://github.com/goldspecdigital/oooas/issues/52
This package works find on PHP 8.0 but fails on PHP 8.1 without the return typehints for ArrayAccess
.
We are using it as a depencency of vyuldashev/laravel-openapi
@matthew-inamdar Can you please merge this?
@matthew-inamdar This fix allows us to use the package, can you please merge this?
Sorry for the delay - I've been struggling for time recently.
These type hints will be a breaking change for currently supported PHP versions.
If we added the #[\ReturnTypeWillChange]
attribute, would that suffice?
@matthew-inamdar Yes, that would suffice!
@matthew-inamdar Thinking about my previous comment, adding a ReturnTypeWillChange attribute will be a bigger change than adding return type as it will drop support for any PHP version below 8.1. What exactly are you worried about regarding breaking changes with return types? The interface in PHP already has the return types specified, so it should not be really any issue.
@matthew-inamdar Thinking about my previous comment, adding a ReturnTypeWillChange attribute will be a bigger change than adding return type as it will drop support for any PHP version below 8.1. What exactly are you worried about regarding breaking changes with return types? The interface in PHP already has the return types specified, so it should not be really any issue.
This won't be an issue due to the way attributes were designed in PHP. The attribute will work fine in php8.0 as no instance is actually created for it. As for any PHP version before PHP 8, the #
prefix for attributes will be seen as comments by the engine, so the lines will just be skipped :)
TL;DR using #[\ReturnTypeWillChange]
will not be a breaking change.
@matthew-inamdar if you would like, I could open a new PR with the ReturnTypeWillChange
attribute and one that adds PHP 8.0 and 8.1 to the test matrix?
@matthew-inamdar would be great to get your accept 🤓
This PR is now obsolete as #55 as discussed above has been merged and released in 2.9.0. @judgej or @matthew-inamdar this PR can be closed then, right?
Hey, this is still needed.
On v2.10.0
I was getting:
09:34:58 INFO [deprecation] User Deprecated: Method "ArrayAccess::offsetSet()" might add "void" as a native return type declaration in the future. Do the same in implementation "GoldSpecDigital\ObjectOrientedOAS\Utilities\Extensions" now to avoid errors or add an explicit @return annotation to suppress this message. ["exception" => ErrorException { …}]
09:34:58 INFO [deprecation] User Deprecated: Method "ArrayAccess::offsetUnset()" might add "void" as a native return type declaration in the future. Do the same in implementation "GoldSpecDigital\ObjectOrientedOAS\Utilities\Extensions" now to avoid errors or add an explicit @return annotation to suppress this message. ["exception" => ErrorException { …}]
This MR fixes the deprecation. Thank you!
Rebase: https://github.com/adrienbrault/oooas/commit/f24ceb1d0d5d9d1e2547c4b8797c6514220b8f69