Phpunit: ReflectionType::__toString() is deprecated in PHP 7.4

Created on 20 Jun 2019  路  8Comments  路  Source: sebastianbergmann/phpunit

| 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

statuwaiting-for-feedback

Most helpful comment

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 :)

All 8 comments

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

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

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 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

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

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.

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 :)

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebastianbergmann picture sebastianbergmann  路  3Comments

stemis picture stemis  路  3Comments

ezzatron picture ezzatron  路  3Comments

sebastianbergmann picture sebastianbergmann  路  4Comments

AnmSaiful picture AnmSaiful  路  4Comments