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

feat: Enable the usage of "psr/http-message": "^1.0|^2.0" #6338

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

jeromegamez
Copy link
Contributor

@jeromegamez jeromegamez commented Jun 10, 2023

Closes #6243

Notes

BREAKING_CHANGE_REASON=Covariant return types are supported starting with PHP 7.4. The added return types only narrow down the return types. (https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters)

:octocat:

@jeromegamez jeromegamez requested review from a team as code owners June 10, 2023 07:16
@jeromegamez jeromegamez marked this pull request as draft June 10, 2023 07:29
@jeromegamez jeromegamez force-pushed the psr-http-message-2 branch 2 times, most recently from 4e0e415 to 4d09ab1 Compare June 10, 2023 08:09
@jeromegamez jeromegamez marked this pull request as ready for review June 10, 2023 08:16
@jeromegamez jeromegamez requested a review from a team as a code owner June 10, 2023 08:16
Versions 5.26.5|6.9.6|7.3.1 remove `psr/http-message` from their direct
dependencies to not block the installation of more recent
versions.
@@ -47,7 +47,7 @@ public function __construct(StreamInterface $stream)
*
* @return int The size of the stream.
*/
public function getSize()
public function getSize(): ?int
Copy link
Contributor

@bshaffer bshaffer Jun 12, 2023

Choose a reason for hiding this comment

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

won't these changes break compatibility with psr/http-message: ^1.0? Have you tested it with this version of psr/http-message? I think it's fine to accept a breaking change here, but if it doesn't work with 1.0 we should remove that version from composer.json

edit: I tested with psr/http-message:1.0 and it works fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, realizing now that these changes are in Storage and not in Debugger, so we need to be very careful about what we do here as far as breaking customers.

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason this is considered a breaking change is because if someone has made a subclass of ReadStream or WriteStream, and they defined the getSize() method without a return type, then this change would result in a PHP fatal error :

Declaration of SomeCustom\ReadStream::getSize() must be compatible with Google\Cloud\Storage\ReadStream::getSize(): ?int

To avoid this being a breaking change, we would want to add final to the class, or even an @internal label, to signal that it's not meant to be subclassed.

In general I think these changes are benign. I don't think anyone is subclassing these, and if they are, an easy fix would be to just add the return types to the subclassed methods.

@@ -47,7 +47,7 @@ public function __construct(StreamInterface $stream)
*
* @return int The size of the stream.
*/
public function getSize()
public function getSize(): ?int
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, realizing now that these changes are in Storage and not in Debugger, so we need to be very careful about what we do here as far as breaking customers.

@bshaffer bshaffer requested a review from saranshdhingra June 12, 2023 18:09
@bshaffer
Copy link
Contributor

Adding @saranshdhingra because we need his approval on the "breaking changes" before merging

@bshaffer bshaffer added do not merge Indicates a pull request not ready for merge, due to either quality or timing. next release PRs to be included in the next release and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Jun 12, 2023
@bshaffer bshaffer merged commit b3967d3 into googleapis:main Jun 20, 2023
@jeromegamez
Copy link
Contributor Author

Thank you for merging 🙏🏻🌺

@jeromegamez jeromegamez deleted the psr-http-message-2 branch June 20, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change allowed next release PRs to be included in the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add compatibility for psr/http-message 2.0 version
3 participants