|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This software package is licensed under AGPL, Commercial license. |
|
5
|
|
|
* |
|
6
|
|
|
* @package maslosoft/addendum |
|
7
|
|
|
* @licence AGPL, Commercial |
|
8
|
|
|
* @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes) |
|
9
|
|
|
* @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes) |
|
10
|
|
|
* @copyright Copyright (c) Jan Suchal (Original version, builder, parser) |
|
11
|
|
|
* @link http://maslosoft.com/addendum/ - maslosoft addendum |
|
12
|
|
|
* @link https://code.google.com/p/addendum/ - original addendum project |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Maslosoft\Addendum\Reflection; |
|
16
|
|
|
|
|
17
|
|
|
use Maslosoft\Addendum\Builder\DocComment; |
|
18
|
|
|
use Maslosoft\Addendum\Exceptions\MultipleClassesInFileException; |
|
19
|
|
|
use Maslosoft\Addendum\Exceptions\NoClassInFileException; |
|
20
|
|
|
use ReflectionExtension; |
|
21
|
|
|
use ReflectionMethod; |
|
22
|
|
|
use ReflectionProperty; |
|
23
|
|
|
use Reflector; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* ReflectionFile |
|
27
|
|
|
* TODO Stubbed reflection class for file, without including this file |
|
28
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
29
|
|
|
*/ |
|
30
|
|
|
class ReflectionFile implements Reflector |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
const IS_IMPLICIT_ABSTRACT = 16; |
|
34
|
|
|
const IS_EXPLICIT_ABSTRACT = 32; |
|
35
|
|
|
const IS_FINAL = 64; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Class anme |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
public $name = ''; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Extracted docs |
|
45
|
|
|
* @var mixed[] |
|
46
|
|
|
*/ |
|
47
|
|
|
private $_docs = []; |
|
48
|
|
|
private $namespace; |
|
49
|
|
|
private $shortName; |
|
50
|
|
|
private $file; |
|
51
|
|
|
private $methods; |
|
52
|
|
|
private $fields; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* (PHP 5)<br/> |
|
56
|
|
|
* Constructs a ReflectionClass from file |
|
57
|
|
|
* @link http://php.net/manual/en/reflectionclass.construct.php |
|
58
|
|
|
* @param string $file <p> |
|
59
|
|
|
* Either a string containing the name of the class to |
|
60
|
|
|
* reflect, or an object. |
|
61
|
|
|
* </p> |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function __construct($file) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$docExtractor = new DocComment(); |
|
66
|
1 |
|
$this->_docs = $docExtractor->forFile($file); |
|
|
|
|
|
|
67
|
1 |
|
$this->file = $file; |
|
68
|
1 |
|
$this->methods = $this->_docs['methods']; |
|
69
|
1 |
|
$this->fields = $this->_docs['fields']; |
|
70
|
|
|
|
|
71
|
1 |
|
$this->namespace = $this->_docs['namespace']; |
|
72
|
1 |
|
$this->shortName = $this->_docs['className']; |
|
73
|
1 |
|
if (empty($this->shortName)) |
|
74
|
1 |
|
{ |
|
75
|
|
|
throw new NoClassInFileException(sprintf("Could not find any class in file `%s`", $file)); |
|
76
|
|
|
} |
|
77
|
1 |
|
if (is_array($this->shortName)) |
|
78
|
1 |
|
{ |
|
79
|
|
|
throw new MultipleClassesInFileException(sprintf("`%s` does not support multiple classes. Found in file `%s`", __CLASS__, $file)); |
|
80
|
|
|
} |
|
81
|
1 |
|
$this->name = $this->namespace . '\\' . $this->shortName; |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
final private function __clone() |
|
85
|
|
|
{ |
|
86
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function __toString() |
|
90
|
|
|
{ |
|
91
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* (PHP 5)<br/> |
|
96
|
|
|
* Exports a class |
|
97
|
|
|
* @link http://php.net/manual/en/reflectionclass.export.php |
|
98
|
|
|
* @param mixed $argument <p> |
|
|
|
|
|
|
99
|
|
|
* The reflection to export. |
|
100
|
|
|
* </p> |
|
101
|
|
|
* @param bool $return [optional] <p> |
|
|
|
|
|
|
102
|
|
|
* Setting to <b>TRUE</b> will return the export, |
|
103
|
|
|
* as opposed to emitting it. Setting to <b>FALSE</b> (the default) will do the opposite. |
|
104
|
|
|
* </p> |
|
105
|
|
|
* @return string If the <i>return</i> parameter |
|
106
|
|
|
* is set to <b>TRUE</b>, then the export is returned as a string, |
|
107
|
|
|
* otherwise <b>NULL</b> is returned. |
|
108
|
|
|
*/ |
|
109
|
|
|
public static function export() |
|
110
|
|
|
{ |
|
111
|
|
|
|
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* (PHP 5)<br/> |
|
116
|
|
|
* Gets class name |
|
117
|
|
|
* @link http://php.net/manual/en/reflectionclass.getname.php |
|
118
|
|
|
* @return string The class name. |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getName() |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->name; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* (PHP 5)<br/> |
|
127
|
|
|
* Checks if class is defined internally by an extension, or the core |
|
128
|
|
|
* @link http://php.net/manual/en/reflectionclass.isinternal.php |
|
129
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
130
|
|
|
*/ |
|
131
|
|
|
public function isInternal() |
|
132
|
|
|
{ |
|
133
|
|
|
|
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* (PHP 5)<br/> |
|
138
|
|
|
* Checks if user defined |
|
139
|
|
|
* @link http://php.net/manual/en/reflectionclass.isuserdefined.php |
|
140
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
141
|
|
|
*/ |
|
142
|
|
|
public function isUserDefined() |
|
143
|
|
|
{ |
|
144
|
|
|
return true; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* (PHP 5)<br/> |
|
149
|
|
|
* Checks if the class is instantiable |
|
150
|
|
|
* @link http://php.net/manual/en/reflectionclass.isinstantiable.php |
|
151
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
152
|
|
|
*/ |
|
153
|
|
|
public function isInstantiable() |
|
154
|
|
|
{ |
|
155
|
|
|
|
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* (PHP >= 5.4.0)<br/> |
|
160
|
|
|
* Returns whether this class is cloneable |
|
161
|
|
|
* @link http://php.net/manual/en/reflectionclass.iscloneable.php |
|
162
|
|
|
* @return bool <b>TRUE</b> if the class is cloneable, <b>FALSE</b> otherwise. |
|
163
|
|
|
*/ |
|
164
|
|
|
public function isCloneable() |
|
165
|
|
|
{ |
|
166
|
|
|
|
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* (PHP 5)<br/> |
|
171
|
|
|
* Gets the filename of the file in which the class has been defined |
|
172
|
|
|
* @link http://php.net/manual/en/reflectionclass.getfilename.php |
|
173
|
|
|
* @return string the filename of the file in which the class has been defined. |
|
174
|
|
|
* If the class is defined in the PHP core or in a PHP extension, <b>FALSE</b> |
|
175
|
|
|
* is returned. |
|
176
|
|
|
*/ |
|
177
|
|
|
public function getFileName() |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->file; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* (PHP 5)<br/> |
|
184
|
|
|
* Gets starting line number |
|
185
|
|
|
* @link http://php.net/manual/en/reflectionclass.getstartline.php |
|
186
|
|
|
* @return int The starting line number, as an integer. |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getStartLine() |
|
189
|
|
|
{ |
|
190
|
|
|
|
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* (PHP 5)<br/> |
|
195
|
|
|
* Gets end line |
|
196
|
|
|
* @link http://php.net/manual/en/reflectionclass.getendline.php |
|
197
|
|
|
* @return int The ending line number of the user defined class, or <b>FALSE</b> if unknown. |
|
198
|
|
|
*/ |
|
199
|
|
|
public function getEndLine() |
|
200
|
|
|
{ |
|
201
|
|
|
|
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
206
|
|
|
* Gets doc comments |
|
207
|
|
|
* @link http://php.net/manual/en/reflectionclass.getdoccomment.php |
|
208
|
|
|
* @return string The doc comment if it exists, otherwise <b>FALSE</b> |
|
209
|
|
|
*/ |
|
210
|
|
|
public function getDocComment() |
|
211
|
|
|
{ |
|
212
|
|
|
|
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* (PHP 5)<br/> |
|
217
|
|
|
* Gets the constructor of the class |
|
218
|
|
|
* @link http://php.net/manual/en/reflectionclass.getconstructor.php |
|
219
|
|
|
* @return ReflectionMethod A <b>ReflectionMethod</b> object reflecting the class' constructor, or <b>NULL</b> if the class |
|
220
|
|
|
* has no constructor. |
|
221
|
|
|
*/ |
|
222
|
|
|
public function getConstructor() |
|
223
|
|
|
{ |
|
224
|
|
|
|
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
229
|
|
|
* Checks if method is defined |
|
230
|
|
|
* @link http://php.net/manual/en/reflectionclass.hasmethod.php |
|
231
|
|
|
* @param string $name <p> |
|
232
|
|
|
* Name of the method being checked for. |
|
233
|
|
|
* </p> |
|
234
|
|
|
* @return bool <b>TRUE</b> if it has the method, otherwise <b>FALSE</b> |
|
235
|
|
|
*/ |
|
236
|
|
|
public function hasMethod($name) |
|
237
|
|
|
{ |
|
238
|
|
|
return array_key_exists($name, $this->methods); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* (PHP 5)<br/> |
|
243
|
|
|
* Gets a <b>ReflectionMethod</b> for a class method. |
|
244
|
|
|
* @link http://php.net/manual/en/reflectionclass.getmethod.php |
|
245
|
|
|
* @param string $name <p> |
|
246
|
|
|
* The method name to reflect. |
|
247
|
|
|
* </p> |
|
248
|
|
|
* @return ReflectionMethod A <b>ReflectionMethod</b>. |
|
249
|
|
|
*/ |
|
250
|
|
|
public function getMethod($name) |
|
|
|
|
|
|
251
|
|
|
{ |
|
252
|
|
|
|
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* (PHP 5)<br/> |
|
257
|
|
|
* Gets an array of methods |
|
258
|
|
|
* @link http://php.net/manual/en/reflectionclass.getmethods.php |
|
259
|
|
|
* @param int $filter [optional] <p> |
|
260
|
|
|
* Filter the results to include only methods with certain attributes. Defaults |
|
261
|
|
|
* to no filtering. |
|
262
|
|
|
* </p> |
|
263
|
|
|
* <p> |
|
264
|
|
|
* Any combination of <b>ReflectionMethod::IS_STATIC</b>, |
|
265
|
|
|
* <b>ReflectionMethod::IS_PUBLIC</b>, |
|
266
|
|
|
* <b>ReflectionMethod::IS_PROTECTED</b>, |
|
267
|
|
|
* <b>ReflectionMethod::IS_PRIVATE</b>, |
|
268
|
|
|
* <b>ReflectionMethod::IS_ABSTRACT</b>, |
|
269
|
|
|
* <b>ReflectionMethod::IS_FINAL</b>. |
|
270
|
|
|
* </p> |
|
271
|
|
|
* @return array An array of <b>ReflectionMethod</b> objects |
|
272
|
|
|
* reflecting each method. |
|
273
|
|
|
*/ |
|
274
|
|
|
public function getMethods($filter = null) |
|
|
|
|
|
|
275
|
|
|
{ |
|
276
|
|
|
|
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
281
|
|
|
* Checks if property is defined |
|
282
|
|
|
* @link http://php.net/manual/en/reflectionclass.hasproperty.php |
|
283
|
|
|
* @param string $name <p> |
|
284
|
|
|
* Name of the property being checked for. |
|
285
|
|
|
* </p> |
|
286
|
|
|
* @return bool <b>TRUE</b> if it has the property, otherwise <b>FALSE</b> |
|
287
|
|
|
*/ |
|
288
|
|
|
public function hasProperty($name) |
|
289
|
|
|
{ |
|
290
|
|
|
return array_key_exists($name, $this->fields); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* (PHP 5)<br/> |
|
295
|
|
|
* Gets a <b>ReflectionProperty</b> for a class's property |
|
296
|
|
|
* @link http://php.net/manual/en/reflectionclass.getproperty.php |
|
297
|
|
|
* @param string $name <p> |
|
298
|
|
|
* The property name. |
|
299
|
|
|
* </p> |
|
300
|
|
|
* @return ReflectionProperty A <b>ReflectionProperty</b>. |
|
301
|
|
|
*/ |
|
302
|
|
|
public function getProperty($name) |
|
|
|
|
|
|
303
|
|
|
{ |
|
304
|
|
|
|
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* (PHP 5)<br/> |
|
309
|
|
|
* Gets properties |
|
310
|
|
|
* @link http://php.net/manual/en/reflectionclass.getproperties.php |
|
311
|
|
|
* @param int $filter [optional] <p> |
|
312
|
|
|
* The optional filter, for filtering desired property types. It's configured using |
|
313
|
|
|
* the ReflectionProperty constants, |
|
314
|
|
|
* and defaults to all property types. |
|
315
|
|
|
* </p> |
|
316
|
|
|
* @return array An array of <b>ReflectionProperty</b> objects. |
|
317
|
|
|
*/ |
|
318
|
|
|
public function getProperties($filter = null) |
|
|
|
|
|
|
319
|
|
|
{ |
|
320
|
|
|
|
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
325
|
|
|
* Checks if constant is defined |
|
326
|
|
|
* @link http://php.net/manual/en/reflectionclass.hasconstant.php |
|
327
|
|
|
* @param string $name <p> |
|
328
|
|
|
* The name of the constant being checked for. |
|
329
|
|
|
* </p> |
|
330
|
|
|
* @return bool <b>TRUE</b> if the constant is defined, otherwise <b>FALSE</b>. |
|
331
|
|
|
*/ |
|
332
|
|
|
public function hasConstant($name) |
|
|
|
|
|
|
333
|
|
|
{ |
|
334
|
|
|
|
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* (PHP 5)<br/> |
|
339
|
|
|
* Gets constants |
|
340
|
|
|
* @link http://php.net/manual/en/reflectionclass.getconstants.php |
|
341
|
|
|
* @return array An array of constants. |
|
342
|
|
|
* Constant name in key, constant value in value. |
|
343
|
|
|
*/ |
|
344
|
|
|
public function getConstants() |
|
345
|
|
|
{ |
|
346
|
|
|
|
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* (PHP 5)<br/> |
|
351
|
|
|
* Gets defined constant |
|
352
|
|
|
* @link http://php.net/manual/en/reflectionclass.getconstant.php |
|
353
|
|
|
* @param string $name <p> |
|
354
|
|
|
* Name of the constant. |
|
355
|
|
|
* </p> |
|
356
|
|
|
* @return mixed Value of the constant. |
|
357
|
|
|
*/ |
|
358
|
|
|
public function getConstant($name) |
|
|
|
|
|
|
359
|
|
|
{ |
|
360
|
|
|
|
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* (PHP 5)<br/> |
|
365
|
|
|
* Gets the interfaces |
|
366
|
|
|
* @link http://php.net/manual/en/reflectionclass.getinterfaces.php |
|
367
|
|
|
* @return array An associative array of interfaces, with keys as interface |
|
368
|
|
|
* names and the array values as <b>ReflectionClass</b> objects. |
|
369
|
|
|
*/ |
|
370
|
|
|
public function getInterfaces() |
|
371
|
|
|
{ |
|
372
|
|
|
|
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* (PHP 5 >= 5.2.0)<br/> |
|
377
|
|
|
* Gets the interface names |
|
378
|
|
|
* @link http://php.net/manual/en/reflectionclass.getinterfacenames.php |
|
379
|
|
|
* @return array A numerical array with interface names as the values. |
|
380
|
|
|
*/ |
|
381
|
|
|
public function getInterfaceNames() |
|
382
|
|
|
{ |
|
383
|
|
|
|
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* (PHP 5)<br/> |
|
388
|
|
|
* Checks if the class is an interface |
|
389
|
|
|
* @link http://php.net/manual/en/reflectionclass.isinterface.php |
|
390
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
391
|
|
|
*/ |
|
392
|
|
|
public function isInterface() |
|
393
|
|
|
{ |
|
394
|
|
|
|
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* (PHP >= 5.4.0)<br/> |
|
399
|
|
|
* Returns an array of traits used by this class |
|
400
|
|
|
* @link http://php.net/manual/en/reflectionclass.gettraits.php |
|
401
|
|
|
* @return array an array with trait names in keys and instances of trait's |
|
402
|
|
|
* <b>ReflectionClass</b> in values. |
|
403
|
|
|
* Returns <b>NULL</b> in case of an error. |
|
404
|
|
|
*/ |
|
405
|
|
|
public function getTraits() |
|
406
|
|
|
{ |
|
407
|
|
|
|
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
/** |
|
411
|
|
|
* (PHP >= 5.4.0)<br/> |
|
412
|
|
|
* Returns an array of names of traits used by this class |
|
413
|
|
|
* @link http://php.net/manual/en/reflectionclass.gettraitnames.php |
|
414
|
|
|
* @return array an array with trait names in values. |
|
415
|
|
|
* Returns <b>NULL</b> in case of an error. |
|
416
|
|
|
*/ |
|
417
|
|
|
public function getTraitNames() |
|
418
|
|
|
{ |
|
419
|
|
|
|
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
/** |
|
423
|
|
|
* (PHP >= 5.4.0)<br/> |
|
424
|
|
|
* Returns an array of trait aliases |
|
425
|
|
|
* @link http://php.net/manual/en/reflectionclass.gettraitaliases.php |
|
426
|
|
|
* @return array an array with new method names in keys and original names (in the |
|
427
|
|
|
* format "TraitName::original") in values. |
|
428
|
|
|
* Returns <b>NULL</b> in case of an error. |
|
429
|
|
|
*/ |
|
430
|
|
|
public function getTraitAliases() |
|
431
|
|
|
{ |
|
432
|
|
|
|
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* (PHP >= 5.4.0)<br/> |
|
437
|
|
|
* Returns whether this is a trait |
|
438
|
|
|
* @link http://php.net/manual/en/reflectionclass.istrait.php |
|
439
|
|
|
* @return bool <b>TRUE</b> if this is a trait, <b>FALSE</b> otherwise. |
|
440
|
|
|
* Returns <b>NULL</b> in case of an error. |
|
441
|
|
|
*/ |
|
442
|
|
|
public function isTrait() |
|
443
|
|
|
{ |
|
444
|
|
|
|
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* (PHP 5)<br/> |
|
449
|
|
|
* Checks if class is abstract |
|
450
|
|
|
* @link http://php.net/manual/en/reflectionclass.isabstract.php |
|
451
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
452
|
|
|
*/ |
|
453
|
|
|
public function isAbstract() |
|
454
|
|
|
{ |
|
455
|
|
|
|
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* (PHP 5)<br/> |
|
460
|
|
|
* Checks if class is final |
|
461
|
|
|
* @link http://php.net/manual/en/reflectionclass.isfinal.php |
|
462
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
463
|
|
|
*/ |
|
464
|
|
|
public function isFinal() |
|
465
|
|
|
{ |
|
466
|
|
|
|
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
/** |
|
470
|
|
|
* (PHP 5)<br/> |
|
471
|
|
|
* Gets modifiers |
|
472
|
|
|
* @link http://php.net/manual/en/reflectionclass.getmodifiers.php |
|
473
|
|
|
* @return int bitmask of |
|
474
|
|
|
* modifier constants. |
|
475
|
|
|
*/ |
|
476
|
|
|
public function getModifiers() |
|
477
|
|
|
{ |
|
478
|
|
|
|
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
/** |
|
482
|
|
|
* (PHP 5)<br/> |
|
483
|
|
|
* Checks class for instance |
|
484
|
|
|
* @link http://php.net/manual/en/reflectionclass.isinstance.php |
|
485
|
|
|
* @param object $object <p> |
|
486
|
|
|
* The object being compared to. |
|
487
|
|
|
* </p> |
|
488
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
489
|
|
|
*/ |
|
490
|
|
|
public function isInstance($object) |
|
|
|
|
|
|
491
|
|
|
{ |
|
492
|
|
|
|
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* (PHP 5)<br/> |
|
497
|
|
|
* Creates a new class instance from given arguments. |
|
498
|
|
|
* @link http://php.net/manual/en/reflectionclass.newinstance.php |
|
499
|
|
|
* @param mixed $args <p> |
|
500
|
|
|
* Accepts a variable number of arguments which are passed to the class |
|
501
|
|
|
* constructor, much like <b>call_user_func</b>. |
|
502
|
|
|
* </p> |
|
503
|
|
|
* @param mixed $_ [optional] |
|
504
|
|
|
* @return object |
|
505
|
|
|
*/ |
|
506
|
|
|
public function newInstance($args, $_ = null) |
|
|
|
|
|
|
507
|
|
|
{ |
|
508
|
|
|
|
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
/** |
|
512
|
|
|
* (PHP >= 5.4.0)<br/> |
|
513
|
|
|
* Creates a new class instance without invoking the constructor. |
|
514
|
|
|
* @link http://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php |
|
515
|
|
|
* @return object |
|
516
|
|
|
*/ |
|
517
|
|
|
public function newInstanceWithoutConstructor() |
|
518
|
|
|
{ |
|
519
|
|
|
|
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
/** |
|
523
|
|
|
* (PHP 5 >= 5.1.3)<br/> |
|
524
|
|
|
* Creates a new class instance from given arguments. |
|
525
|
|
|
* @link http://php.net/manual/en/reflectionclass.newinstanceargs.php |
|
526
|
|
|
* @param array $args [optional] <p> |
|
527
|
|
|
* The parameters to be passed to the class constructor as an array. |
|
528
|
|
|
* </p> |
|
529
|
|
|
* @return object a new instance of the class. |
|
530
|
|
|
*/ |
|
531
|
|
|
public function newInstanceArgs(array $args = null) |
|
|
|
|
|
|
532
|
|
|
{ |
|
533
|
|
|
|
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
/** |
|
537
|
|
|
* (PHP 5)<br/> |
|
538
|
|
|
* Gets parent class |
|
539
|
|
|
* @link http://php.net/manual/en/reflectionclass.getparentclass.php |
|
540
|
|
|
* @return object A <b>ReflectionClass</b>. |
|
541
|
|
|
*/ |
|
542
|
|
|
public function getParentClass() |
|
543
|
|
|
{ |
|
544
|
|
|
|
|
545
|
|
|
} |
|
546
|
|
|
|
|
547
|
|
|
/** |
|
548
|
|
|
* (PHP 5)<br/> |
|
549
|
|
|
* Checks if a subclass |
|
550
|
|
|
* @link http://php.net/manual/en/reflectionclass.issubclassof.php |
|
551
|
|
|
* @param string $class <p> |
|
552
|
|
|
* The class name being checked against. |
|
553
|
|
|
* </p> |
|
554
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
555
|
|
|
*/ |
|
556
|
|
|
public function isSubclassOf($class) |
|
|
|
|
|
|
557
|
|
|
{ |
|
558
|
|
|
|
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
/** |
|
562
|
|
|
* (PHP 5)<br/> |
|
563
|
|
|
* Gets static properties |
|
564
|
|
|
* @link http://php.net/manual/en/reflectionclass.getstaticproperties.php |
|
565
|
|
|
* @return array The static properties, as an array. |
|
566
|
|
|
*/ |
|
567
|
|
|
public function getStaticProperties() |
|
568
|
|
|
{ |
|
569
|
|
|
|
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
574
|
|
|
* Gets static property value |
|
575
|
|
|
* @link http://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php |
|
576
|
|
|
* @param string $name <p> |
|
577
|
|
|
* The name of the static property for which to return a value. |
|
578
|
|
|
* </p> |
|
579
|
|
|
* @param mixed $def_value [optional] <p> |
|
580
|
|
|
* </p> |
|
581
|
|
|
* @return mixed The value of the static property. |
|
582
|
|
|
*/ |
|
583
|
|
|
public function getStaticPropertyValue($name, &$def_value = null) |
|
|
|
|
|
|
584
|
|
|
{ |
|
585
|
|
|
|
|
586
|
|
|
} |
|
587
|
|
|
|
|
588
|
|
|
/** |
|
589
|
|
|
* (PHP 5 >= 5.1.0)<br/> |
|
590
|
|
|
* Sets static property value |
|
591
|
|
|
* @link http://php.net/manual/en/reflectionclass.setstaticpropertyvalue.php |
|
592
|
|
|
* @param string $name <p> |
|
593
|
|
|
* Property name. |
|
594
|
|
|
* </p> |
|
595
|
|
|
* @param string $value <p> |
|
596
|
|
|
* New property value. |
|
597
|
|
|
* </p> |
|
598
|
|
|
* @return void No value is returned. |
|
599
|
|
|
*/ |
|
600
|
|
|
public function setStaticPropertyValue($name, $value) |
|
|
|
|
|
|
601
|
|
|
{ |
|
602
|
|
|
|
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
/** |
|
606
|
|
|
* (PHP 5)<br/> |
|
607
|
|
|
* Gets default properties |
|
608
|
|
|
* @link http://php.net/manual/en/reflectionclass.getdefaultproperties.php |
|
609
|
|
|
* @return array An array of default properties, with the key being the name of |
|
610
|
|
|
* the property and the value being the default value of the property or <b>NULL</b> |
|
611
|
|
|
* if the property doesn't have a default value. The function does not distinguish |
|
612
|
|
|
* between static and non static properties and does not take visibility modifiers |
|
613
|
|
|
* into account. |
|
614
|
|
|
*/ |
|
615
|
|
|
public function getDefaultProperties() |
|
616
|
|
|
{ |
|
617
|
|
|
|
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
/** |
|
621
|
|
|
* (PHP 5)<br/> |
|
622
|
|
|
* Checks if iterateable |
|
623
|
|
|
* @link http://php.net/manual/en/reflectionclass.isiterateable.php |
|
624
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
625
|
|
|
*/ |
|
626
|
|
|
public function isIterateable() |
|
627
|
|
|
{ |
|
628
|
|
|
|
|
629
|
|
|
} |
|
630
|
|
|
|
|
631
|
|
|
/** |
|
632
|
|
|
* (PHP 5)<br/> |
|
633
|
|
|
* Implements interface |
|
634
|
|
|
* @link http://php.net/manual/en/reflectionclass.implementsinterface.php |
|
635
|
|
|
* @param string $interface <p> |
|
636
|
|
|
* The interface name. |
|
637
|
|
|
* </p> |
|
638
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
639
|
|
|
*/ |
|
640
|
|
|
public function implementsInterface($interface) |
|
|
|
|
|
|
641
|
|
|
{ |
|
642
|
|
|
|
|
643
|
|
|
} |
|
644
|
|
|
|
|
645
|
|
|
/** |
|
646
|
|
|
* (PHP 5)<br/> |
|
647
|
|
|
* Gets a <b>ReflectionExtension</b> object for the extension which defined the class |
|
648
|
|
|
* @link http://php.net/manual/en/reflectionclass.getextension.php |
|
649
|
|
|
* @return ReflectionExtension A <b>ReflectionExtension</b> object representing the extension which defined the class, |
|
650
|
|
|
* or <b>NULL</b> for user-defined classes. |
|
651
|
|
|
*/ |
|
652
|
|
|
public function getExtension() |
|
653
|
|
|
{ |
|
654
|
|
|
return null; |
|
655
|
|
|
} |
|
656
|
|
|
|
|
657
|
|
|
/** |
|
658
|
|
|
* (PHP 5)<br/> |
|
659
|
|
|
* Gets the name of the extension which defined the class |
|
660
|
|
|
* @link http://php.net/manual/en/reflectionclass.getextensionname.php |
|
661
|
|
|
* @return string The name of the extension which defined the class, or <b>FALSE</b> for user-defined classes. |
|
662
|
|
|
*/ |
|
663
|
|
|
public function getExtensionName() |
|
664
|
|
|
{ |
|
665
|
|
|
return false; |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
/** |
|
669
|
|
|
* (PHP 5 >= 5.3.0)<br/> |
|
670
|
|
|
* Checks if in namespace |
|
671
|
|
|
* @link http://php.net/manual/en/reflectionclass.innamespace.php |
|
672
|
|
|
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
|
673
|
|
|
*/ |
|
674
|
|
|
public function inNamespace() |
|
675
|
|
|
{ |
|
676
|
|
|
return strlen($this->namespace) > 1; |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
/** |
|
680
|
|
|
* (PHP 5 >= 5.3.0)<br/> |
|
681
|
|
|
* Gets namespace name |
|
682
|
|
|
* @link http://php.net/manual/en/reflectionclass.getnamespacename.php |
|
683
|
|
|
* @return string The namespace name. |
|
684
|
|
|
*/ |
|
685
|
|
|
public function getNamespaceName() |
|
686
|
|
|
{ |
|
687
|
|
|
return $this->namespace; |
|
688
|
|
|
} |
|
689
|
|
|
|
|
690
|
|
|
/** |
|
691
|
|
|
* (PHP 5 >= 5.3.0)<br/> |
|
692
|
|
|
* Gets short name |
|
693
|
|
|
* @link http://php.net/manual/en/reflectionclass.getshortname.php |
|
694
|
|
|
* @return string The class short name. |
|
695
|
|
|
*/ |
|
696
|
|
|
public function getShortName() |
|
697
|
|
|
{ |
|
698
|
|
|
return $this->shortName; |
|
699
|
|
|
} |
|
700
|
|
|
|
|
701
|
|
|
} |
|
702
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..