Backward Compatibility
PHPUnit follows Semantic Versioning. Tests, configuration files, and extensions that only use what this page lists as covered keep working until the next major version.
Release Schedule
| Version | Released | What it may change |
|---|---|---|
| Major | Each year on the first Friday of February | Makes incompatible changes: removes features that were hard-deprecated, hard-deprecates features that were soft-deprecated, and may raise the minimum required version of PHP |
| Minor | On the first Friday of April, June, August, October, and December | Adds functionality in a backward compatible manner and may deprecate features |
| Patch | As needed | Addresses issues in a backward compatible manner |
The Supported Versions page shows which versions of PHPUnit currently receive bug fixes.
What is covered
The backward compatibility promise for PHPUnit covers the following. None of it changes in an incompatible manner in a minor or patch version.
| What | Promise |
|---|---|
| PHP code | Classes, interfaces, traits, enumerations, and methods that are not annotated with @internal can be used in the same way. The exceptions are listed below |
| XML configuration file | Elements and attributes keep their name and their meaning |
| CLI options | Options of the test runner keep their name and their meaning |
| Exit codes | The shell exit codes of the test runner keep their meaning |
| Logfiles | What is written to a logfile in JUnit XML, Open Test Reporting XML, or TeamCity format keeps its meaning. A minor version may add information |
| Events | Events and subscriber interfaces that exist keep working. A minor version may add events, see Sequence of events |
| PHP | The minimum required version of PHP is only raised in a major version |
What is not covered
Internal Code
PHPUnit's units of code that are annotated with @internal are not covered by the backward compatibility promise for PHPUnit. This annotation is used on classes, interfaces, traits, and enumerations as well as on individual methods of a class that itself is not internal.
Internal code is subject to change or removal even in minor or patch versions. It must not be used in third-party code: not in test code, not in extensions for PHPUnit, and not in wrappers around PHPUnit.
Named Arguments
Parameter names are not covered by the backward compatibility promise for PHPUnit: a parameter may be renamed in a minor or patch version. The @no-named-arguments annotation on PHPUnit's classes, interfaces, traits, and enumerations documents this. Use positional arguments when you call a method of PHPUnit or use one of its attributes.
The only exception is the PHPUnit\Framework\PropertyBased\Generators class of PHPUnit 14 and newer. Its methods have several optional parameters and are meant to be called with named arguments. Their parameter names are covered.
Objects created by PHPUnit
PHPUnit passes objects to third-party code: subscribers receive events and the value objects that describe a test or a test suite, including its metadata, and extensions receive the configuration of the test runner. For these objects, only the public methods for querying information are covered by the backward compatibility promise for PHPUnit. How these objects are created is not covered: their constructors and static factory methods are internal.
Since there is no point in extending these classes outside of PHPUnit's own code, making an abstract class of such a value object abstract readonly, for example, is not considered to be a break of backward compatibility.
Interfaces implemented only by PHPUnit
Some interfaces exist so that third-party code can use objects that PHPUnit creates, not so that third-party code can implement them. Examples are MockObject and Stub for test doubles, InvocationStubber and InvocationMocker for configuring them, and the Facade that an extension receives when it is bootstrapped. Some of these interfaces are annotated with @phpstan-sealed, so that static analysis reports a class that implements them outside of PHPUnit.
Adding a method to such an interface in a minor version is not considered to be a break of backward compatibility.
Sequence of events
Which events are emitted during a test run, and in which order, is not fixed for a major version. A minor version may emit events that did not exist before. Any version, including a patch version, may correct the sequence of events when it was wrong.
Subscribers depend on the sequence of events, though. A change to it that existing subscribers have to be adapted to may therefore have to wait until the next major version, even when the current sequence is flawed. For example, the guarantee that a test or a test suite that is started is also finished, and that the event for a hook method is emitted before that method is called, changes when events that already exist are emitted. This change was made in PHPUnit 14 and not in a minor version of PHPUnit 13.
Output of the test runner
What the test runner prints, for instance the progress, the result, the details about issues, and the TestDox output, is meant to be read by humans and may change in any version. Do not parse it. A tool that needs to process the result of a test run should read a logfile or subscribe to events instead.
Deprecation and Removal
A feature is removed in three steps:
| Step | When | What you notice |
|---|---|---|
| Soft deprecation | In a minor version | IDEs and static analysis tools report the use of the feature. Tests work as before |
| Hard deprecation | In the next major version | PHPUnit reports the use of the feature. Tests work as before |
| Removal | In the major version after that | Tests that use the feature no longer work |
For example, assertContainsOnly() was soft-deprecated in PHPUnit 11.5, hard-deprecated in PHPUnit 12, and removed in PHPUnit 13.
Soft Deprecation
The @deprecated annotation is added to the unit of code through which the feature is used, for instance a method. IDEs and static analysis tools can now report that deprecated functionality is used.
Tests that use a soft-deprecated assertion method, for example, will continue to work in exactly the same way.
Hard Deprecation
The feature is hard-deprecated in the next major version after it was soft-deprecated.
Tests that use a hard-deprecated assertion method, for example, will continue to work in exactly the same way. The only difference is that PHPUnit now reports that a hard-deprecated feature is used. This does not make the test run fail unless the test runner is configured to fail on PHPUnit deprecations, for instance with the --fail-on-phpunit-deprecation CLI option.
Hard Deprecation without Soft Deprecation
A soft deprecation needs a unit of code that the @deprecated annotation can be added to. Where there is none, the feature is hard-deprecated directly, in a minor or patch version. This applies to:
- a CLI option of the test runner
- an element, an attribute, or the value of an attribute of the XML configuration file
- a value that is passed as an argument to a method that itself is not deprecated
- calling a method in a situation in which this will no longer be supported
For example, the --dont-report-useless-tests CLI option was hard-deprecated in PHPUnit 12.2.3 and removed in PHPUnit 13.
Removal
The feature is removed in the next major version after it was hard-deprecated.
Tests that use an assertion method that was removed, for example, will no longer work.
Deprecations
The following pages list the features that are deprecated in each major version of PHPUnit:
Version Control
Tags
Tags in PHPUnit's Git repository are immutable. We do not change published tags to point to a different revision, for example.
In very rare cases we may delete a tag in order to unpublish a broken release. The new release that fixes what was broken will always have a different tag than the one that was unpublished.
Branches
Branches in PHPUnit's Git repository are private implementation details. For example, we delete branches for versions of PHPUnit that are no longer supported.