From 744a796800aad6434665db85cd2e4dc7e306866d Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Mon, 22 Aug 2022 11:27:09 +0200 Subject: [PATCH] Document the problem described in https://github.com/sebastianbergmann/phpunit/issues/5033#issuecomment-1221992857 as well as possible workarounds --- src/installation.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/installation.rst b/src/installation.rst index bef66b8c0..dc85e09f0 100644 --- a/src/installation.rst +++ b/src/installation.rst @@ -192,6 +192,34 @@ dependencies of your project: composer require --dev phpunit/phpunit ^\ |version| +Installing PHPUnit with Composer on PHP 8.2 +=========================================== + +PHPUnit 4.5 added a dependency on Prophecy, an alternative to PHPUnit's own test double functionality, +and introduced out-of-the-box support for it. The latter is `deprecated `_ +since PHPUnit 9.1 and will be removed in PHPUnit 10. PHPUnit 10 also no longer depends on Prophecy. + +At the time of writing (August 2022), `Prophecy does not yet support PHP 8.2 `_. +This means that PHPUnit |version|, which does support PHP 8.2, cannot be installed using Composer without workarounds +until there is a released version of Prophecy that supports PHP 8.2. + +One workaround is to use Composer's CLI option ``--ignore-platform-req=PHP`` to ignore the PHP version requirement. This will install ``phpspec/prophecy`` as well as its dependencies despite the fact that the ``composer.json`` file for ``phpspec/prophecy`` has a PHP version constraint that intends to prohibit the installation of Prophecy on PHP 8.2. + +Another workaround is to add this section to your project's ``composer.json`` file: + +.. parsed-literal:: + + "replace": { "phpspec/prophecy": "*" } + +The above will prevent the installation of ``phpspec/prophecy``. + +Both workarounds shown above will only allow you to install PHPUnit |version| on PHP 8.2. +Tests that use Prophecy may or may not work using the first workaround, but cannot work with the second workaround as Prophecy will not be available. + +If you use PHPUnit from a PHP Archive (PHAR), see above, you are not affected by this issue. + +This issue is discussed in more detail `here `_. + .. _installation.global: Global Installation