@@ -31,54 +31,47 @@ namespace Phalcon\Annotations;
3131class Reflection
3232{
3333 /**
34- * @var array
35- * TODO: Make always array
34+ * @var Collection|null
3635 */
37- protected classAnnotations;
36+ protected classAnnotations = null ;
3837
3938 /**
4039 * @var array
41- * TODO: Make always array
4240 */
43- protected constantAnnotations;
41+ protected constantAnnotations = [] ;
4442
4543 /**
4644 * @var array
47- * TODO: Make always array
4845 */
49- protected propertyAnnotations;
46+ protected propertyAnnotations = [] ;
5047
5148 /**
5249 * @var array
53- * TODO: Make always array
5450 */
55- protected methodAnnotations;
51+ protected methodAnnotations = [] ;
5652
5753 /**
5854 * @var array
5955 */
6056 protected reflectionData = [];
6157
62- /**
63- * Phalcon\Annotations\Reflection constructor
64- */
6558 public function __construct (array reflectionData = [] )
6659 {
6760 let this -> reflectionData = reflectionData;
6861 }
6962
7063 /**
7164 * Returns the annotations found in the class docblock
65+ *
66+ * @return Collection|null
7267 */
73- public function getClassAnnotations () -> <Collection> | bool
68+ public function getClassAnnotations () -> <Collection> | null
7469 {
7570 var reflectionClass;
7671
7772 if this -> classAnnotations === null {
7873 if fetch reflectionClass, this -> reflectionData[" class" ] {
7974 let this -> classAnnotations = new Collection (reflectionClass);
80- } else {
81- let this -> classAnnotations = false ;
8275 }
8376 }
8477
@@ -87,83 +80,65 @@ class Reflection
8780
8881 /**
8982 * Returns the annotations found in the constants' docblocks
83+ *
84+ * @return Collection[]
9085 */
91- public function getConstantsAnnotations () -> < Collection[]> | bool
86+ public function getConstantsAnnotations () -> < Collection[]>
9287 {
9388 var reflectionConstants, constant, reflectionConstant;
9489
95- if this -> constantAnnotations === null {
96- if fetch reflectionConstants, this -> reflectionData[" constants" ] {
97- if count(reflectionConstants) {
98- let this -> constantAnnotations = [];
99-
100- for constant, reflectionConstant in reflectionConstants {
101- let this -> constantAnnotations[constant] = new Collection (
102- reflectionConstant
103- );
104- }
105-
106- return this -> constantAnnotations;
90+ if fetch reflectionConstants, this -> reflectionData[" constants" ] {
91+ if typeof reflectionConstants === " array" && count(reflectionConstants) > 0 {
92+ for constant, reflectionConstant in reflectionConstants {
93+ let this -> constantAnnotations[constant] = new Collection (
94+ reflectionConstant
95+ );
10796 }
10897 }
109-
110- let this -> constantAnnotations = false ;
11198 }
11299
113100 return this -> constantAnnotations;
114101 }
115102
116103 /**
117104 * Returns the annotations found in the properties' docblocks
105+ *
106+ * @return Collection[]
118107 */
119- public function getPropertiesAnnotations () -> < Collection[]> | bool
108+ public function getPropertiesAnnotations () -> < Collection[]>
120109 {
121110 var reflectionProperties, property, reflectionProperty;
122111
123- if this -> propertyAnnotations === null {
124- if fetch reflectionProperties, this -> reflectionData[" properties" ] {
125- if count(reflectionProperties) {
126- let this -> propertyAnnotations = [];
127-
128- for property, reflectionProperty in reflectionProperties {
129- let this -> propertyAnnotations[property] = new Collection (
130- reflectionProperty
131- );
132- }
133-
134- return this -> propertyAnnotations;
112+ if fetch reflectionProperties, this -> reflectionData[" properties" ] {
113+ if typeof reflectionProperties === " array" && count(reflectionProperties) > 0 {
114+ for property, reflectionProperty in reflectionProperties {
115+ let this -> propertyAnnotations[property] = new Collection (
116+ reflectionProperty
117+ );
135118 }
136119 }
137-
138- let this -> propertyAnnotations = false ;
139120 }
140121
141122 return this -> propertyAnnotations;
142123 }
143124
144125 /**
145126 * Returns the annotations found in the methods' docblocks
127+ *
128+ * @return Collection[]
146129 */
147- public function getMethodsAnnotations () -> < Collection[]> | bool
130+ public function getMethodsAnnotations () -> < Collection[]>
148131 {
149132 var reflectionMethods, methodName, reflectionMethod;
150133
151- if this -> methodAnnotations === null {
152- if fetch reflectionMethods, this -> reflectionData[" methods" ] {
153- if count(reflectionMethods) {
154- let this -> methodAnnotations = [];
155-
156- for methodName, reflectionMethod in reflectionMethods {
157- let this -> methodAnnotations[methodName] = new Collection (
158- reflectionMethod
159- );
160- }
161-
162- return this -> methodAnnotations;
134+ if fetch reflectionMethods, this -> reflectionData[" methods" ] {
135+ if typeof reflectionMethods === " array" && count(reflectionMethods) > 0 {
136+ for methodName, reflectionMethod in reflectionMethods {
137+ let this -> methodAnnotations[methodName] = new Collection (
138+ reflectionMethod
139+ );
163140 }
164141 }
165-
166- let this -> methodAnnotations = false ;
167142 }
168143
169144 return this -> methodAnnotations;
@@ -172,6 +147,8 @@ class Reflection
172147 /**
173148 * Returns the raw parsing intermediate definitions used to construct the
174149 * reflection
150+ *
151+ * @return array
175152 */
176153 public function getReflectionData () -> array
177154 {
0 commit comments