MediaWiki REL1_41
AnnotationReader.php
Go to the documentation of this file.
1<?php
2
4
12 private static $cache = [];
13
21 public static function propertyHasAnnotation(
22 \ReflectionProperty $property,
23 string $annotationName
24 ) {
25 $cacheKey = "$annotationName@{$property->class}::{$property->name}";
26 if ( !isset( self::$cache[$cacheKey] ) ) {
27 $comment = $property->getDocComment();
28 if ( $comment === false ) {
29 self::$cache[$cacheKey] = false;
30 } else {
31 $encAnnotation = preg_quote( $annotationName, '!' );
32 self::$cache[$cacheKey] =
33 (bool)preg_match( "!^[ \t]*(/\*\*|\*)[ \t]*@$encAnnotation\b!im", $comment );
34 }
35 }
36 return self::$cache[$cacheKey];
37 }
38}
Utility class for reading doc comment annotations.
static propertyHasAnnotation(\ReflectionProperty $property, string $annotationName)
Determine whether a ReflectionProperty has a specified annotation.