sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.67k stars 2.2k forks source link

Support PHP 8 #4325

Closed sebastianbergmann closed 4 years ago

sebastianbergmann commented 4 years ago

PHPUnit 9 is being tested against nightly builds of PHP 8 for quite a while and it is safe to say that -- as of right now -- PHPUnit 9 works on PHP 8. While some things might still change until PHP 8.0.0 is released, it is time to make the support for PHP 8 official.

However, this is not as simple as applying

diff --git a/composer.json b/composer.json
index 0f8416d1d..2bf0fa21e 100644
--- a/composer.json
+++ b/composer.json
@@ -22,7 +22,7 @@
     "prefer-stable": true,
     "minimum-stability": "dev",
     "require": {
-        "php": "^7.3",
+        "php": "^7.3 || ^8.0",

to this repository for phpunit/phpunit.

PHP 8.0 also needs to be allowed in the composer.json files of PHPUnit's dependencies:

$ composer info | sort -d
doctrine/instantiator              1.3.1             A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                  1.9.5             Create deep copies (clones) of your objects
phar-io/manifest                   1.0.3             Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    2.0.1             Library for handling version information and constraints
phpdocumentor/reflection-common    2.1.0             Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.1.0             With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver        1.2.0             A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy-phpunit           v2.0.0            PhpUnit test case integrating the Prophecy mocking library
phpspec/prophecy                   v1.10.3           Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.0.x-dev 4b3293f Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          3.0.2             FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                3.0.1             Invoke callables with a timeout
phpunit/php-text-template          2.0.1             Simple template engine.
phpunit/php-timer                  5.0.0             Utility class for timing
phpunit/php-token-stream           4.0.2             Wrapper around PHP's tokenizer extension.
sebastian/code-unit                1.0.3             Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.1             Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.2             Provides the functionality to compare PHP values for equality
sebastian/diff                     4.0.1             Diff implementation
sebastian/environment              5.1.1             Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.1             Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.x-dev 836ce3a Snapshotting of global state
sebastian/object-enumerator        4.0.1             Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         2.0.1             Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        4.0.1             Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.1             Provides a list of PHP built-in functions that operate on resources
sebastian/type                     2.1.0             Collection of value objects that represent the types of the PHP type system
sebastian/version                  3.0.0             Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-ctype             v1.17.1           Symfony polyfill for ctype functions
theseer/tokenizer                  1.1.3             A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.9.0             Assertions to validate method input/output with nice error messages.

Of course, I will take care of all dependencies that live in the sebastian/ and phpunit/ namespaces myself.

mfn commented 4 years ago

Awesome preparations done so head of time! Although I'm not involved, I did enjoy the level of enthusiasm and professionalism how things are done and looking forward.

Thank you all ❤️

GrahamCampbell commented 4 years ago

not all PHPUnit's dependencies actually allow PHP 8 yet

Prophecy doesn't allow PHP 8 yet. It requires ^7.2 still.

tuupola commented 4 years ago

Maybe in the future prophecy could be considered to be an optional dependency? Currently there are too many hoops to jump through to test code with multiple versions of PHP if testing with PHP 8 is included. Not a biggie if testing only with PHP 8.

stof commented 4 years ago

@tuupola removing support for Prophecy in core is planned for the future, which is why phpspec/prophecy-phpunit was resurrected.

dereuromark commented 4 years ago

Ran into the same issue today with https://travis-ci.org/github/milesj/decoda/jobs/728420774 and PHP8 being untestable.

//EDIT: using --ignore-platform-reqs works as a workaround for now.

ciaranmcnulty commented 3 years ago

Prophecy 1.12.0 was just tagged which allows php 8.0

praad commented 3 years ago

Composer update on Mac Osx Big Sur

Problem 1