phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

ReflectionType::__toString() is deprecated in PHP 7.4

Open henryruhs opened this issue 7 years ago • 9 comments

Q A
PHPUnit version 8.1.3
PHP version 7.4snapshot
Installation Method Composer

Hello,

I have an issue on Travis CI using PHPUnit with convertWarningsToExceptions.

Function ReflectionType::__toString() is deprecated

It only happens in tests using getMockBuilder so this must be related to that the deprecation (since PHP 5.5.0) that now is throwing an warning: https://php.net/manual/de/reflectiontype.tostring.php

henryruhs avatar Jun 20 '19 20:06 henryruhs

PHPUnit 8.1.3 is no longer supported. Please try with PHPUnit 8.2.3, thanks.

sebastianbergmann avatar Jun 21 '19 04:06 sebastianbergmann

Awesome, I got it back working using the latest version. Thank you Sebastian...

henryruhs avatar Jun 21 '19 15:06 henryruhs

We have the same issue on PHPUnit 6.5, and the framework does not support > 6 here. Is there a way to patch out the PHPUnit 6 series to be PHP7.4 compatible?

EDIT To be precise: Part of the test harness is about PHP5.6 testing, as such the PHPUnit 6 series is needed here still.

dereuromark avatar Aug 15 '19 19:08 dereuromark

@dereuromark i have similar issue in Crunz, here is how i solved it: create patched class (PHPUnit_Framework_MockObject_Generator), then use PHPUnit's bootstrap file to replace original class with patched one when PHP version is same or newer than 7.1. Whole PR for reference: https://github.com/lavary/crunz/commit/8ef1370aa47009fd1945fb73f0414bd88634ada2

PabloKowalczyk avatar Sep 28 '19 09:09 PabloKowalczyk

Quite annoying to have to do that on like 30 repos etc though :/

dereuromark avatar Sep 28 '19 09:09 dereuromark

I am sure that Sebastian does not give support for PHPUnit 6 to get PHP 7.4 running as he is very strict when it comes to end of life. 😆

Not a good idea to comment a closed issue aswell, open a fresh one with your description.

henryruhs avatar Sep 28 '19 09:09 henryruhs

I am sure that Sebastian does not give support for PHPUnit 6

Actually I'm using PHPUnit 5.7, because I need PHP 5.6 support :)

PabloKowalczyk avatar Sep 28 '19 10:09 PabloKowalczyk

You cannot support both as new PHPUnit versions enforce return types for setup() and tearDown() ... so even with fancy CI that installes PHPUnit according to PHP version: this is a dead end!

  1. You can have 2 testing suites
  2. Rewrite testing suite files to PHP5 on the fly
  3. Finally, drop that old shit

henryruhs avatar Sep 28 '19 10:09 henryruhs

PHPUnit 8.1.3 is no longer supported. Please try with PHPUnit 8.2.3, thanks.

@sebastianbergmann Could you please let me know what should be the compatible version of allure-framework/allure-phpunit when we upgrade to PHPUnit 8.2.3?

I am getting this error - https://github.com/allure-framework/allure-phpunit/issues/40

Thanks

dazimax avatar Jun 09 '21 22:06 dazimax