summaryrefslogtreecommitdiffstats
path: root/phpunit-mock-objects-php74.patch
blob: fc1c9fd5675dafcab347f04394ffae53f6e1105b (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 5
https://github.com/sebastianbergmann/phpunit/commit/e11397fed729bfef7a9c76f7b193c27ad5710f6b

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();
+            if (PHP_VERSION_ID >= 70100) {
+                $returnType = $method->getReturnType()->getName();
+            } else {
+                $returnType = (string) $method->getReturnType();
+            }
         } else {
             $returnType = '';
         }
@@ -1190,12 +1194,19 @@ class PHPUnit_Framework_MockObject_Gener
             $typeDeclaration = '';
 
             if (!$forCall) {
-                if ($this->hasType($parameter) && (string) $parameter->getType() !== '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 = $typename . ' ';
                 } elseif ($parameter->isArray()) {
                     $typeDeclaration = 'array ';
                 } elseif ($parameter->isCallable()) {