-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathFirst.php
190 lines (158 loc) · 4.44 KB
/
First.php
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
declare(strict_types = 1);
/*
* Go! AOP framework
*
* @copyright Copyright 2018, Lisachenko Alexander <[email protected]>
*
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/
namespace Go\Stubs;
use Closure;
use Countable;
use Exception;
use Iterator;
#[StubAttribute(First::class)]
class First
{
private int $private = T_PRIVATE;
protected int $protected = T_PROTECTED;
public int $public = T_PUBLIC;
#[StubAttribute(First::class)]
public string $publicWithAttribute = 'attribute';
private static int $staticPrivate = T_PRIVATE;
protected static int $staticProtected = T_PROTECTED;
protected static int $staticPublic = T_PUBLIC;
// Dynamic methods that access $this-> properties
private function privateMethod(): int
{
return $this->private;
}
protected function protectedMethod(): int
{
return $this->protected;
}
/**
* @return int Some description
*/
public function publicMethod(): int
{
return $this->public;
}
public final function publicFinalMethod(): void
{
// nothing here
}
protected final function protectedFinalMethod(): void
{
// nothing here
}
/**
* @link https://github.com/laminas/laminas-code/pull/145 For tracking why attributes are not suuported
*/
#[StubAttribute(First::class)]
public function publicMethodWithAttribute(#[StubAttribute("argument")] string $argument): string
{
return $argument;
}
public function publicMethodWithUnionTypeReturn(Exception|Closure $value): Exception|Closure
{
return $value;
}
public function publicMethodWithIntersectionTypeReturn(Exception&Countable $value): Exception&Countable
{
return $value;
}
public function publicMethodWithDNFTypeReturn(Iterator|(Exception&Countable) $value): Iterator|(Exception&Countable)
{
return $value;
}
// Static methods that access self:: properties
private static function staticSelfPrivate(): int
{
return self::$staticPrivate;
}
protected static function staticSelfProtected(): int
{
return self::$staticProtected;
}
public static function staticSelfPublic(): int
{
return self::$staticPublic;
}
public static function staticSelfPublicAccessPrivate(): int
{
return self::$staticPrivate;
}
protected static function staticLsbProtected(): string
{
return get_called_class();
}
public static function staticLsbPublic(): string
{
return get_called_class();
}
// Pass by reference
public function passByReference(&$valueByReference)
{
$valueByReference = null;
return $valueByReference;
}
// Pass by reference
public static function staticPassByReference(&$valueByReference)
{
$valueByReference = null;
return $valueByReference;
}
// Recursion test
public function recursion(int $value, int $level = 0): int
{
if ($level > 0) {
$value += $this->recursion($value, $level-1);
}
return $value;
}
// Recursion test
public static function staticLsbRecursion(int $value, int $level = 0): int
{
if ($level > 0) {
$value += static::staticLsbRecursion($value, $level-1);
}
return $value;
}
/**
* Method for checking invocation with any number of arguments
*
* NB: Real proxy use the method definition to prepare invocation proxy, so variable number of arguments
* will not work at all!
*/
public function variableArgsTest(): string
{
return implode('', func_get_args());
}
/**
* Method for checking variadic arguments
*/
public function variadicArgsTest(...$args): string
{
return implode('', $args);
}
/**
* Method for checking invocation with any number of arguments
*
* NB: Real proxy use the method definition to prepare invocation proxy, so variable number of arguments
* will not work at all!
*/
public static function staticVariableArgsTest(): string
{
return implode('', func_get_args());
}
/**
* Method for checking static variadic arguments
*/
public static function staticVariadicArgsTest(...$args): string
{
return implode('', $args);
}
}