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

[PHP] Fix deprecations in PHP 8.1 #11743

Merged
merged 4 commits into from
Mar 15, 2022

Conversation

satackey
Copy link
Contributor

Fixed the following deprecations in PHP 8.1. This pull request resolves #11742.

Deprecated: Return type of XXXX::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ...

Added the #[\ReturnTypeWillChange] attribute or the same type hint as the internal interface to the return value of methods that implement PHP's internal interface ArrayAccess.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09) ❤️, @ybelenko (2018/07), @renepardon (2018/12)

@ksvirkou-hubspot
Copy link
Contributor

Hi Everyone
It is really important changes
Could anyone check it please?
@jebentier @dkarlovi @mandrean @jfastnacht @ackintosh @ybelenko @renepardon

@ksvirkou-hubspot
Copy link
Contributor

@ybelenko
Copy link
Contributor

Gonna take care of it tomorrow. Sorry, too much daytime work. I want to pay maximum attention to all php based generators in the March. Next major release with breaking changes scheduled to the end of the month, I will have to wait for a year to add significant changes if I miss that deadline. Crazy. Thanks for patience.

@@ -424,6 +425,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[\ReturnTypeWillChange]
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't use mixed type(accepted in PHP 8) to make it compatible with PHP 7.4, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. PHP 7.4 is in the security support period, so I thought we shouldn't make breaking changes until it goes EOL.

@satackey satackey requested a review from ybelenko March 14, 2022 06:26
@ybelenko
Copy link
Contributor

@satackey You didn't test your own PR? Should at least mention that, we don't always check PRs locally. It's a luck that I noticed boolean typehint from a brief look.

@satackey
Copy link
Contributor Author

@ybelenko I used this code that creates an instance of the object for testing and confirmed that the deprecation notice disappears, I hadn't tested it to cover the change.
Thank you for your review. I appreciate it.

Copy link
Contributor

@ybelenko ybelenko left a comment

Choose a reason for hiding this comment

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

Just checked locally under PHP 7.4, 8.0 and 8.1. Works without notices or errors across versions.

@ybelenko ybelenko merged commit 213828d into OpenAPITools:master Mar 15, 2022
@wing328 wing328 added this to the 6.0.0 milestone Apr 4, 2022
kasperg added a commit to danskernesdigitalebibliotek/dpl-cms that referenced this pull request Nov 23, 2023
Without this our client will issue deprecation warnings. This has been
fixed in 6.x but we go for the latest version of 7.x to keep things
updated.

See OpenAPITools/openapi-generator#11743

Note that this may cause the current situation to be invalid as the
client depends on Guzzle 7 while Drupaæ 9 still depends on Guzzle 6.

This should be resolved shortly with the update to Drupal 10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQ][PHP] PHP 8.1 Support
4 participants