Annotations.php
2.3 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
<?php
/**
* This file is part of the php-annotation framework.
*
* (c) Rasmus Schultz <rasmus@mindplay.dk>
*
* This software is licensed under the GNU LGPL license
* for more information, please see:
*
* <https://github.com/mindplay-dk/php-annotations>
*/
namespace mindplay\annotations;
/**
* Thin, static class with shortcut methods for inspection of Annotations
*
* Using this static wrapper is optional - if your application uses a service container
* or a dependency injection container, you most likely want to configure an instance
* of the AnnotationManager using that layer instead.
*/
abstract class Annotations
{
/**
* @var array Configuration for any public property of AnnotationManager.
*/
public static $config;
/**
* @var AnnotationManager Singleton AnnotationManager instance
*/
private static $manager;
/**
* @return AnnotationManager a singleton instance
*/
public static function getManager()
{
if (!isset(self::$manager)) {
self::$manager = new AnnotationManager;
}
if (is_array(self::$config)) {
foreach (self::$config as $key => $value) {
self::$manager->$key = $value;
}
}
return self::$manager;
}
/**
* Returns the UsageAnnotation for the annotation with the given class-name.
*
* @see AnnotationManager::getUsage()
*/
public static function getUsage($class)
{
return self::getManager()->getUsage($class);
}
/**
* Inspects class Annotations
*
* @see AnnotationManager::getClassAnnotations()
*/
public static function ofClass($class, $type = null)
{
return self::getManager()->getClassAnnotations($class, $type);
}
/**
* Inspects method Annotations
*
* @see AnnotationManager::getMethodAnnotations()
*/
public static function ofMethod($class, $method = null, $type = null)
{
return self::getManager()->getMethodAnnotations($class, $method, $type);
}
/**
* Inspects property Annotations
*
* @see AnnotationManager::getPropertyAnnotations()
*/
public static function ofProperty($class, $property = null, $type = null)
{
return self::getManager()->getPropertyAnnotations($class, $property, $type);
}
}