@@ -80,10 +80,10 @@ public static function getUsage(string $class): UsageAnnotation
8080 *
8181 * @see AnnotationManager::getClassAnnotations()
8282 *
83- * @param string| object $class
84- * @param string|null $type
83+ * @param object $class The class name or instance.
84+ * @param string $type The name of the annotation.
8585 *
86- * @return array|Annotation []
86+ * @return IAnnotation []
8787 *
8888 * @throws Exceptions\AnnotationException
8989 */
@@ -97,11 +97,11 @@ public static function ofClass($class, string $type = null): array
9797 *
9898 * @see AnnotationManager::getMethodAnnotations()
9999 *
100- * @param $class
101- * @param string|null $method
102- * @param string|null $type
100+ * @param object $class The class name or instance.
101+ * @param string $method The name of the method.
102+ * @param string $type The name of the annotation.
103103 *
104- * @return array
104+ * @return IAnnotation[]
105105 *
106106 * @throws Exceptions\AnnotationException
107107 */
@@ -115,16 +115,63 @@ public static function ofMethod($class, string $method = null, string $type = nu
115115 *
116116 * @see AnnotationManager::getPropertyAnnotations()
117117 *
118- * @param $class
119- * @param string|null $property
120- * @param string|null $type
118+ * @param object $class The class name or instance.
119+ * @param string $property The name of the property.
120+ * @param string $type The name of the annotation.
121121 *
122- * @return array| IAnnotation[]
122+ * @return IAnnotation[]
123123 *
124124 * @throws Exceptions\AnnotationException
125125 */
126126 public static function ofProperty ($ class , string $ property = null , string $ type = null ): array
127127 {
128128 return self ::getManager ()->getPropertyAnnotations ($ class , $ property , $ type );
129129 }
130+
131+ /**
132+ * Checks if a class has the given annotation.
133+ *
134+ * @param object $class The class name or instance.
135+ * @param string $type The name of the annotation.
136+ *
137+ * @return bool
138+ *
139+ * @throws Exceptions\AnnotationException
140+ */
141+ public static function classHasAnnotation ($ class , string $ type )
142+ {
143+ return count (self ::ofClass ($ class , $ type )) > 0 ;
144+ }
145+
146+ /**
147+ * Checks if a class method has the given annotation.
148+ *
149+ * @param object $class The class name or instance.
150+ * @param string $method The name of the method.
151+ * @param string $type The name of the annotation.
152+ *
153+ * @return bool
154+ *
155+ * @throws Exceptions\AnnotationException
156+ */
157+ public static function methodHasAnnotation ($ class , string $ method , string $ type )
158+ {
159+ return count (self ::ofMethod ($ class , $ method , $ type )) > 0 ;
160+ }
161+
162+ /**
163+ * Checks if a class property has the given annotation.
164+ *
165+ * @param object $class The class name or instance.
166+ * @param string $property The name of the property.
167+ * @param string $type The name of the annotation.
168+ *
169+ * @return bool
170+ *
171+ * @throws Exceptions\AnnotationException
172+ */
173+ public static function propertyHasAnnotation ($ class , string $ property , string $ type )
174+ {
175+ return count (self ::ofProperty ($ class , $ property , $ type )) > 0 ;
176+ }
130177}
0 commit comments