1 | <?php |
||
49 | class StackFrame |
||
50 | { |
||
51 | /** |
||
52 | * which class has been executed? |
||
53 | * |
||
54 | * @var string|null |
||
55 | */ |
||
56 | private $class; |
||
57 | |||
58 | /** |
||
59 | * which function or method has been executed? |
||
60 | * |
||
61 | * @var string|null |
||
62 | */ |
||
63 | private $function; |
||
64 | |||
65 | /** |
||
66 | * how was the function or method called? |
||
67 | * |
||
68 | * @var string|null |
||
69 | */ |
||
70 | private $callType; |
||
71 | |||
72 | /** |
||
73 | * which file was the code in? |
||
74 | * |
||
75 | * @var string|null |
||
76 | */ |
||
77 | private $file; |
||
78 | |||
79 | /** |
||
80 | * which line in $file was the code on? |
||
81 | * |
||
82 | * @var int|null |
||
83 | */ |
||
84 | private $line; |
||
85 | |||
86 | /** |
||
87 | * what were the contents of the call stack at the time? |
||
88 | * |
||
89 | * @var array |
||
90 | */ |
||
91 | private $stack; |
||
92 | |||
93 | /** |
||
94 | * constructor |
||
95 | * |
||
96 | * @param string|null $class |
||
97 | * which class has been executed? |
||
98 | * @param string|null $function |
||
99 | * which function or method has been executed? |
||
100 | * @param string|null $callType |
||
101 | * how was $function called? |
||
102 | * @param string|null $file |
||
103 | * which file was the calling code in? |
||
104 | * @param int|null $line |
||
105 | * which line in $file was the calling code on? |
||
106 | * @param array $stack |
||
107 | * what was the call stack at the time? |
||
108 | */ |
||
109 | public function __construct($class, $function, $callType, $file, $line, $stack = []) |
||
118 | |||
119 | /** |
||
120 | * which class has been executed? |
||
121 | * |
||
122 | * @return string|null |
||
123 | */ |
||
124 | public function getClass() |
||
128 | |||
129 | /** |
||
130 | * which function or method has been executed? |
||
131 | * |
||
132 | * @return string|null |
||
133 | */ |
||
134 | public function getFunction() |
||
138 | |||
139 | /** |
||
140 | * which method has been executed? |
||
141 | * |
||
142 | * @return string|null |
||
143 | */ |
||
144 | public function getMethod() |
||
151 | |||
152 | /** |
||
153 | * how was the function|method called? |
||
154 | * |
||
155 | * @return string|null |
||
156 | */ |
||
157 | public function getCallType() |
||
161 | |||
162 | /** |
||
163 | * which file was the executed code defined in? |
||
164 | * |
||
165 | * @return string|null |
||
166 | */ |
||
167 | public function getFilename() |
||
171 | |||
172 | /** |
||
173 | * which line in $this->getFile() was the executed code defined on? |
||
174 | * |
||
175 | * @return int|null |
||
176 | */ |
||
177 | public function getLine() |
||
181 | |||
182 | /** |
||
183 | * what were the contents of the call stack at the time? |
||
184 | * |
||
185 | * an empty array means that we weren't asked to save the call stack |
||
186 | * (probably to save memory - the call stack can be large) |
||
187 | * |
||
188 | * @return array |
||
189 | */ |
||
190 | public function getStack() |
||
194 | |||
195 | // ========================================================================= |
||
196 | // |
||
197 | // HELPERS |
||
198 | // |
||
199 | // ------------------------------------------------------------------------- |
||
200 | |||
201 | /** |
||
202 | * return our contents as a sensible, printable string |
||
203 | * |
||
204 | * @return string |
||
|
|||
205 | */ |
||
206 | public function getExecutedCodeSummary() |
||
227 | |||
228 | /** |
||
229 | * return our contents as a sensible, printable string |
||
230 | * |
||
231 | * @return string |
||
232 | */ |
||
233 | public function __toString() |
||
237 | } |
||
238 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.