From 7cfb5a46625e63740714953cafa01a1b2d835d77 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 21 Aug 2019 10:24:21 +0200 Subject: improve patch for 7.4 --- php-phpunit-PHPUnit-MockObject.spec | 2 +- phpunit-mock-objects-php74.patch | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/php-phpunit-PHPUnit-MockObject.spec b/php-phpunit-PHPUnit-MockObject.spec index 6b654f6..8bdf6ad 100644 --- a/php-phpunit-PHPUnit-MockObject.spec +++ b/php-phpunit-PHPUnit-MockObject.spec @@ -135,7 +135,7 @@ EOF : Run tests - set include_path to ensure PHPUnit autoloader use it ret=0 -for cmd in php php70 php71 php72 php73 php74; do +for cmd in php php71 php72 php73 php74; do if which $cmd; then $cmd -d include_path=.:%{buildroot}%{php_home}:%{php_home} \ %{_bindir}/phpunit --no-coverage || ret=1 diff --git a/phpunit-mock-objects-php74.patch b/phpunit-mock-objects-php74.patch index fe31d0f..fc1c9fd 100644 --- a/phpunit-mock-objects-php74.patch +++ b/phpunit-mock-objects-php74.patch @@ -1,30 +1,41 @@ Backported from PHPUnit 7 for PHPUnit 5 https://github.com/sebastianbergmann/phpunit/commit/e11397fed729bfef7a9c76f7b193c27ad5710f6b -diff -up ./src/Framework/MockObject/Generator.php.old ./src/Framework/MockObject/Generator.php ---- ./src/Framework/MockObject/Generator.php.old 2019-08-21 09:46:14.255390916 +0200 -+++ ./src/Framework/MockObject/Generator.php 2019-08-21 09:47:30.829930292 +0200 -@@ -1007,7 +1007,7 @@ class PHPUnit_Framework_MockObject_Gener +diff -up ./src/Framework/MockObject/Generator.php.php74 ./src/Framework/MockObject/Generator.php +--- ./src/Framework/MockObject/Generator.php.php74 2019-08-21 10:15:13.489571552 +0200 ++++ ./src/Framework/MockObject/Generator.php 2019-08-21 10:19:40.211435595 +0200 +@@ -1007,7 +1007,11 @@ class PHPUnit_Framework_MockObject_Gener } if ($this->hasReturnType($method)) { - $returnType = (string) $method->getReturnType(); -+ $returnType = $method->getReturnType()->getName(); ++ if (PHP_VERSION_ID >= 70100) { ++ $returnType = $method->getReturnType()->getName(); ++ } else { ++ $returnType = (string) $method->getReturnType(); ++ } } else { $returnType = ''; } -@@ -1190,12 +1190,12 @@ class PHPUnit_Framework_MockObject_Gener +@@ -1190,12 +1194,19 @@ class PHPUnit_Framework_MockObject_Gener $typeDeclaration = ''; if (!$forCall) { - if ($this->hasType($parameter) && (string) $parameter->getType() !== 'self') { -+ if ($this->hasType($parameter) && $parameter->getType()->getName() !== 'self') { ++ if ($this->hasType($parameter)) { ++ if (PHP_VERSION_ID >= 70100) { ++ $typename = $parameter->getType()->getName(); ++ } else { ++ $typename = (string) $parameter->getType(); ++ } ++ } ++ if ($this->hasType($parameter) && $typename !== 'self') { if (version_compare(PHP_VERSION, '7.1', '>=') && $parameter->allowsNull() && !$parameter->isVariadic()) { $nullable = '?'; } - $typeDeclaration = (string) $parameter->getType() . ' '; -+ $typeDeclaration = $parameter->getType()->getName() . ' '; ++ $typeDeclaration = $typename . ' '; } elseif ($parameter->isArray()) { $typeDeclaration = 'array '; } elseif ($parameter->isCallable()) { -- cgit