Skip to content

Backward Compatibility break in PHPUnit\Framework\Constraint\Constraint #5690

@stof

Description

@stof
Q A
PHPUnit version 11.0
PHP version 8.2.15
Installation Method Composer / PHAR

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

Metadata

Metadata

Labels

type/bugSomething is brokenversion/11Something affects PHPUnit 11

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions