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