summaryrefslogtreecommitdiffstats
path: root/php-phpunit-mock-objects5-php74.patch
blob: 55f49d429ad20afc42597577acad81c82a2f2fad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()) {