@@ -34,30 +34,30 @@ final class AnnotationRegistry
34
34
*
35
35
* @var array
36
36
*/
37
- static private $ autoloadNamespaces = array () ;
37
+ static private $ autoloadNamespaces = [] ;
38
38
39
39
/**
40
40
* A map of autoloader callables.
41
41
*
42
42
* @var array
43
43
*/
44
- static private $ loaders = array () ;
44
+ static private $ loaders = [] ;
45
45
46
46
/**
47
47
* An array of classes which cannot be found
48
48
*
49
49
* @var null[] indexed by class name
50
50
*/
51
- static private $ failedToAutoload = array () ;
51
+ static private $ failedToAutoload = [] ;
52
52
53
53
/**
54
54
* @return void
55
55
*/
56
- static public function reset ()
56
+ public static function reset ()
57
57
{
58
- self ::$ autoloadNamespaces = array () ;
59
- self ::$ loaders = array () ;
60
- self ::$ failedToAutoload = array () ;
58
+ self ::$ autoloadNamespaces = [] ;
59
+ self ::$ loaders = [] ;
60
+ self ::$ failedToAutoload = [] ;
61
61
}
62
62
63
63
/**
@@ -67,7 +67,7 @@ static public function reset()
67
67
*
68
68
* @return void
69
69
*/
70
- static public function registerFile ($ file )
70
+ public static function registerFile ($ file )
71
71
{
72
72
require_once $ file ;
73
73
}
@@ -82,7 +82,7 @@ static public function registerFile($file)
82
82
*
83
83
* @return void
84
84
*/
85
- static public function registerAutoloadNamespace ($ namespace , $ dirs = null )
85
+ public static function registerAutoloadNamespace ($ namespace , $ dirs = null )
86
86
{
87
87
self ::$ autoloadNamespaces [$ namespace ] = $ dirs ;
88
88
}
@@ -96,9 +96,9 @@ static public function registerAutoloadNamespace($namespace, $dirs = null)
96
96
*
97
97
* @return void
98
98
*/
99
- static public function registerAutoloadNamespaces (array $ namespaces )
99
+ public static function registerAutoloadNamespaces (array $ namespaces )
100
100
{
101
- self ::$ autoloadNamespaces = array_merge (self ::$ autoloadNamespaces , $ namespaces );
101
+ self ::$ autoloadNamespaces = \ array_merge (self ::$ autoloadNamespaces , $ namespaces );
102
102
}
103
103
104
104
/**
@@ -113,42 +113,38 @@ static public function registerAutoloadNamespaces(array $namespaces)
113
113
*
114
114
* @throws \InvalidArgumentException
115
115
*/
116
- static public function registerLoader (callable $ callable )
116
+ public static function registerLoader (callable $ callable )
117
117
{
118
118
// Reset our static cache now that we have a new loader to work with
119
- self ::$ failedToAutoload = array () ;
119
+ self ::$ failedToAutoload = [] ;
120
120
self ::$ loaders [] = $ callable ;
121
121
}
122
122
123
123
/**
124
124
* Autoloads an annotation class silently.
125
- *
126
- * @param string $class
127
- *
128
- * @return boolean
129
125
*/
130
- static public function loadAnnotationClass ($ class )
126
+ public static function loadAnnotationClass (string $ class ) : bool
131
127
{
132
128
if (\class_exists ($ class , false )) {
133
129
return true ;
134
130
}
135
131
136
- if (\array_key_exists ($ class , self ::$ failedToAutoload[ $ class ] )) {
132
+ if (\array_key_exists ($ class , self ::$ failedToAutoload )) {
137
133
return false ;
138
134
}
139
135
140
136
foreach (self ::$ autoloadNamespaces AS $ namespace => $ dirs ) {
141
- if (strpos ($ class , $ namespace ) === 0 ) {
142
- $ file = str_replace ("\\" , DIRECTORY_SEPARATOR , $ class ) . " .php " ;
137
+ if (\ strpos ($ class , $ namespace ) === 0 ) {
138
+ $ file = \ str_replace ('\\' , \ DIRECTORY_SEPARATOR , $ class ) . ' .php ' ;
143
139
if ($ dirs === null ) {
144
140
if ($ path = stream_resolve_include_path ($ file )) {
145
141
require $ path ;
146
142
return true ;
147
143
}
148
144
} else {
149
145
foreach ((array )$ dirs AS $ dir ) {
150
- if (is_file ($ dir . DIRECTORY_SEPARATOR . $ file )) {
151
- require $ dir . DIRECTORY_SEPARATOR . $ file ;
146
+ if (is_file ($ dir . \ DIRECTORY_SEPARATOR . $ file )) {
147
+ require $ dir . \ DIRECTORY_SEPARATOR . $ file ;
152
148
return true ;
153
149
}
154
150
}
@@ -157,7 +153,7 @@ static public function loadAnnotationClass($class)
157
153
}
158
154
159
155
foreach (self ::$ loaders AS $ loader ) {
160
- if (call_user_func ( $ loader, $ class ) === true ) {
156
+ if ($ loader( $ class ) === true ) {
161
157
return true ;
162
158
}
163
159
}
0 commit comments