/
return_type_declarations_static.phpt
112 lines (90 loc) · 3.22 KB
/
return_type_declarations_static.phpt
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
--TEST--
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true)
--SKIPIF--
<?php declare(strict_types=1);
if (PHP_MAJOR_VERSION < 8) {
print 'skip: PHP 8 is required.';
}
--FILE--
<?php declare(strict_types=1);
class ClassWithStaticReturnTypes
{
public function returnsStatic(): static
{
}
public function returnsStaticOrNull(): ?static
{
}
public function returnsUnionWithStatic(): static|\stdClass
{
}
}
require __DIR__ . '/../../../../vendor/autoload.php';
$generator = new \PHPUnit\Framework\MockObject\Generator;
$mock = $generator->generate(
'ClassWithStaticReturnTypes',
[],
'MockClassWithStaticReturnTypes',
true,
true
);
print $mock->getClassCode();
--EXPECTF--
declare(strict_types=1);
class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implements PHPUnit\Framework\MockObject\MockObject
{
use \PHPUnit\Framework\MockObject\Api;
use \PHPUnit\Framework\MockObject\Method;
use \PHPUnit\Framework\MockObject\MockedCloneMethod;
public function returnsStatic(): static
{
$__phpunit_arguments = [];
$__phpunit_count = func_num_args();
if ($__phpunit_count > 0) {
$__phpunit_arguments_tmp = func_get_args();
for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
}
}
$__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke(
new \PHPUnit\Framework\MockObject\Invocation(
'ClassWithStaticReturnTypes', 'returnsStatic', $__phpunit_arguments, 'static', $this, true
)
);
return $__phpunit_result;
}
public function returnsStaticOrNull(): ?static
{
$__phpunit_arguments = [];
$__phpunit_count = func_num_args();
if ($__phpunit_count > 0) {
$__phpunit_arguments_tmp = func_get_args();
for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
}
}
$__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke(
new \PHPUnit\Framework\MockObject\Invocation(
'ClassWithStaticReturnTypes', 'returnsStaticOrNull', $__phpunit_arguments, '?static', $this, true
)
);
return $__phpunit_result;
}
public function returnsUnionWithStatic(): static|stdClass
{
$__phpunit_arguments = [];
$__phpunit_count = func_num_args();
if ($__phpunit_count > 0) {
$__phpunit_arguments_tmp = func_get_args();
for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
}
}
$__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke(
new \PHPUnit\Framework\MockObject\Invocation(
'ClassWithStaticReturnTypes', 'returnsUnionWithStatic', $__phpunit_arguments, 'static|stdClass', $this, true
)
);
return $__phpunit_result;
}
}