IPReflectionClass.class.php
3.24 KB
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
<?php
/**
* An extended reflection/documentation class for classes
*
* This class extends the reflectionClass class by also parsing the
* comment for javadoc compatible @tags and by providing help
* functions to generate a WSDL file. THe class might also
* be used to generate a phpdoc on the fly
*
*@author KnowledgeTree Team
*@package Webservice
*@version Version 0.9
*@extends reflectionClass
*/
class IPReflectionClass extends reflectionClass {
/** @var string class name */
public $classname = null;
/** @var string */
public $fullDescription = "";
/** @var string */
public $smallDescription = "";
/** @var IPReflectionMethod[] */
public $methods = Array();
/** @var IPReflectionProperty[] */
public $properties = Array();
/** @var string */
public $extends;
/** @var string */
private $comment = null;
/**
* Constructor
*
* sets the class name and calls the constructor of the reflectionClass
*
* @param string The class name
* @return void
*/
public function __construct($classname){
$this->classname = $classname;
parent::__construct($classname);
$this->parseComment();
}
/**
*Provides all methods exposed by this class as an array
*
* @param boolean If the method should also return protected functions
* @param boolean If the method should also return private functions
* @return IPReflectionMethod[]
*/
public function getMethods($alsoProtected = true, $alsoPrivate = true){
$ar = parent::getMethods();
foreach($ar as $method){
$m = new IPReflectionMethod($this->classname, $method->name);
if((!$m->isPrivate() || $alsoPrivate) && (!$m->isProtected() || $alsoProtected) && ($m->getDeclaringClass()->name == $this->classname))
$this->methods[$method->name] = $m;
}
ksort($this->methods);
return $this->methods;
}
/**
* Exposes an array with public properties of the class
*
* @param boolean If the method should also return protected properties
* @param boolean If the method should also return private properties
* @return IPReflectionProperty[]
*/
public function getProperties($alsoProtected=true,$alsoPrivate=true) {
$ar = parent::getProperties();
$this->properties = Array();
foreach($ar as $property){
if((!$property->isPrivate() || $alsoPrivate) && (!$property->isProtected() || $alsoProtected)){
try{
$p = new IPReflectionProperty($this->classname, $property->getName());
$this->properties[$property->name]=$p;
}catch(ReflectionException $exception){
echo "Fault on property: ".$property->name."<br>\n";
}
}
}
ksort($this->properties);
return $this->properties;
}
/**
* Exposes annotations of the class
* @param $annotationName String the annotation name
* @param $annotationClass String the annotation class
* @return void
*/
public function getAnnotation($annotationName, $annotationClass = null){
return IPPhpDoc::getAnnotation($this->comment, $annotationName, $annotationClass);
}
/**
* Gets all the usefull information from the comments
* @return void
*/
private function parseComment() {
$this->comment = $this->getDocComment();
new IPReflectionCommentParser($this->comment, $this);
}
}
?>