-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add ReturnTypeWillChange to PDO implementations #4662
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 ReturnTypeWillChange to PDO implementations #4662
Conversation
I would consider all PHP CodeSniffer failures to be false positives. Please advice how I should tackle them. Edit:
|
I hope by the time when PHP 8.1 is released we'll drop the support for DBAL 2.x. It has already sucked a lot of blood from us. I don't believe this patch is relevant. |
c386128
to
6d238fb
Compare
I would hope so, but I wouldn't bet on it just yet. 🙈
True!
I've opened the PR because the deprecations bubbled up in Symfony's CI. But there's no urgency to fix them yet. If ORM is compatible with DBAL 3 before PHP 8.1.0 is out, we're fine I guess. That's the only blocker at the moment, isn't it? Then again, once the issues with the CS ruleset have been sorted out, this change isn't particularly heavy. |
I believe so, although I'm not an ORM maintainer or even a user. In any case, it would make more sense to channel the energy to improving the ORM rather than maintaining the 10-years old DBAL API. |
6d238fb
to
be9495a
Compare
I'm ignoring the broken sniff for now. This should yield us a green build. |
Signed-off-by: Alexander M. Turek <me@derrabus.de>
be9495a
to
268e75c
Compare
I've reverted the changes to the CodeSniffer configuration because slevomat/coding-standard#1233 has been fixed in the meantime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @derrabus ! |
@morozov I added some labels, but I'm unsure this qualifies as a bug, feel free to add/remove some of them |
Note, this fails Psalm on PHP 8:
And PHPStan:
|
What would be your recommended course of action? imho, we can safely ignore those errors because defining attributes with an undefined class is a safe thing to do. Alternatively, we could add |
Ignoring the errors in configuration is fine. |
Summary
PHP 8.1 will introduce a process to add return types to internal methods, see https://wiki.php.net/rfc/internal_method_return_types
This library extends various PDO classes and overrides public methods that are affected by this change. PHP 8.1 triggers deprecation warnings unless we declare that a future version of this library will add these return types as well. We can do so by adding the
ReturnTypeWillChange
attribute to those methods.This PR suggests to do just that because adding the actual return types would break code that extends our classes. IIRC, the affected classes have been removed in 3.0 anyway, so let's just get rid of the warnings. 🙂