-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Backward Compatibility break in PHPUnit\Framework\Constraint\Constraint
#5690
Comments
As the change has been rejected in https://wiki.php.net/rfc/readonly_amendments, this |
FTR, the corresponding commit was d82f5ad. I didn't find any discussion around this change though. As @stof said, this change is a huge pain for 3rd party PHPUnit extensions that maintain compatibility for multiple PHPUnit versions. It would be really helpful if we could remove the Then again, removing the |
Nevermind, I'll revert this change and release PHPUnit 11.0.1 in a bit. |
PHPUnit\Framework\Constraint\Constraint
PHPUnit\Framework\Constraint\Constraint
PHPUnit\Framework\Constraint\Constraint
Well, this makes it a huge pain for projects providing custom constraints. It would be great to be able to support the 2 major versions of PHPUnit at the same time (for a package that is dedicated to PHPUnit constraint, making a new major version
doing BC breaks in major version is indeed OK regarding semver. But to me, the fact that it was not announced (while being the most painful BC break of the release) is not. If this was known to be a BC break when doing it, it should have been announced.. Note that the commit included similar changes for some other non-final classes (TestData, TestSuite, etc...). As those are less common in third party code, it might be OK to keep them readonly in 11.x but I would still expect the changelog to be amended for them. |
Thanks for the decision to revert it. It will make things a lot easier. |
PHPUnit 11.0.1 has been released with this fix. |
@sebastianbergmann what about the changelog amending for other non-internal non-final classes that were turned readonly ? |
As far as I can see, this only affects value objects that are passed from PHPUnit's event system to subscribers. Please see the section titled "Event System: Value Objects" that I just added to https://phpunit.de/backward-compatibility.html. |
Thank you very much, @sebastianbergmann! |
there was a BC break in PHPUnit sebastianbergmann/phpunit#5690
there was a BC break in PHPUnit sebastianbergmann/phpunit#5690
Summary
PHPUnit 11.0 has changed the
Constraint
class to mark it readonly. This is a BC break for all child class (i.e. all custom constraints) because PHP requires that child classes have the same readonly flag than their parent (so either both readonly or none).This BC break is not mentioned anywhere in the changelog. And it will make it very hard to define custom constraints compatible with multiple PHPUnit versions as it will require using conditional class definitions.
Current behavior
How to reproduce
Install PHPUnit 11 and use custom constraints that were written against previous versions. See symfony/symfony#53731
Expected behavior
The text was updated successfully, but these errors were encountered: