Skip to content
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

Add return typehints to Extensions ArrayAccess #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

judgej
Copy link

@judgej judgej commented Jan 6, 2022

Fix for #52

@judgej
Copy link
Author

judgej commented Jan 6, 2022

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

@lotyp
Copy link

lotyp commented Mar 2, 2022

@matthew-inamdar Can you please merge this?

@PrinsFrank
Copy link
Contributor

@matthew-inamdar This fix allows us to use the package, can you please merge this?

@matthew-inamdar
Copy link
Member

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?

@PrinsFrank
Copy link
Contributor

PrinsFrank commented Mar 21, 2022

@matthew-inamdar Yes, that would suffice!

@PrinsFrank
Copy link
Contributor

@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.

Copy link
Contributor

@PrinsFrank PrinsFrank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe PHP 8.0 and 8.1 can also be added to the PHP matrix in .github/workflows/tests.yml on line 16?

@TheodoorP
Copy link

@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?

@lotyp
Copy link

lotyp commented May 20, 2022

@matthew-inamdar would be great to get your accept 🤓

@PrinsFrank
Copy link
Contributor

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?

@adrienbrault
Copy link

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: adrienbrault@f24ceb1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants