Backported from PHPUnit 7 for PHPUnit 6 https://github.com/sebastianbergmann/phpunit/commit/e11397fed729bfef7a9c76f7b193c27ad5710f6b diff -up ./src/Generator.php.php74 ./src/Generator.php --- ./src/Generator.php.php74 2019-08-21 10:24:51.680612378 +0200 +++ ./src/Generator.php 2019-08-21 10:26:01.331099137 +0200 @@ -919,7 +919,11 @@ class Generator } if ($method->hasReturnType()) { - $returnType = (string) $method->getReturnType(); + if (PHP_VERSION_ID >= 70100) { + $returnType = $method->getReturnType()->getName(); + } else { + $returnType = (string) $method->getReturnType(); + } } else { $returnType = ''; } @@ -1085,12 +1089,19 @@ class Generator $typeDeclaration = ''; if (!$forCall) { + if ($parameter->hasType()) { + if (PHP_VERSION_ID >= 70100) { + $typename = $parameter->getType()->getName(); + } else { + $typename = (string) $parameter->getType(); + } + } if (PHP_VERSION_ID >= 70100 && $parameter->hasType() && $parameter->allowsNull()) { $nullable = '?'; } - if ($parameter->hasType() && (string) $parameter->getType() !== 'self') { - $typeDeclaration = (string) $parameter->getType() . ' '; + if ($parameter->hasType() && $typename !== 'self') { + $typeDeclaration = $typename . ' '; } elseif ($parameter->isArray()) { $typeDeclaration = 'array '; } elseif ($parameter->isCallable()) {