@@ -47,22 +47,30 @@ final class AnnotationRegistry
47
47
*/
48
48
static private $ failedToAutoload = [];
49
49
50
+ /**
51
+ * Whenever registerFile() was used. Disables use of standard autoloader.
52
+ *
53
+ * @var bool
54
+ */
55
+ static private $ registerFileUsed = false ;
56
+
50
57
public static function reset () : void
51
58
{
52
59
self ::$ autoloadNamespaces = [];
53
60
self ::$ loaders = [];
54
61
self ::$ failedToAutoload = [];
62
+ self ::$ registerFileUsed = false ;
55
63
}
56
64
57
65
/**
58
66
* Registers file.
59
67
*
60
- * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
61
- * autoloading should be deferred to the globally registered autoloader by then. For now,
62
- * use @example AnnotationRegistry::registerLoader('class_exists')
68
+ * @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
63
69
*/
64
70
public static function registerFile (string $ file ) : void
65
71
{
72
+ self ::$ registerFileUsed = true ;
73
+
66
74
require_once $ file ;
67
75
}
68
76
@@ -74,9 +82,7 @@ public static function registerFile(string $file) : void
74
82
* @param string $namespace
75
83
* @param string|array|null $dirs
76
84
*
77
- * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
78
- * autoloading should be deferred to the globally registered autoloader by then. For now,
79
- * use @example AnnotationRegistry::registerLoader('class_exists')
85
+ * @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
80
86
*/
81
87
public static function registerAutoloadNamespace (string $ namespace , $ dirs = null ) : void
82
88
{
@@ -90,9 +96,7 @@ public static function registerAutoloadNamespace(string $namespace, $dirs = null
90
96
*
91
97
* @param string[][]|string[]|null[] $namespaces indexed by namespace name
92
98
*
93
- * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
94
- * autoloading should be deferred to the globally registered autoloader by then. For now,
95
- * use @example AnnotationRegistry::registerLoader('class_exists')
99
+ * @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
96
100
*/
97
101
public static function registerAutoloadNamespaces (array $ namespaces ) : void
98
102
{
@@ -105,9 +109,7 @@ public static function registerAutoloadNamespaces(array $namespaces) : void
105
109
* NOTE: These class loaders HAVE to be silent when a class was not found!
106
110
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
107
111
*
108
- * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
109
- * autoloading should be deferred to the globally registered autoloader by then. For now,
110
- * use @example AnnotationRegistry::registerLoader('class_exists')
112
+ * @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
111
113
*/
112
114
public static function registerLoader (callable $ callable ) : void
113
115
{
@@ -119,7 +121,7 @@ public static function registerLoader(callable $callable) : void
119
121
/**
120
122
* Registers an autoloading callable for annotations, if it is not already registered
121
123
*
122
- * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
124
+ * @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
123
125
*/
124
126
public static function registerUniqueLoader (callable $ callable ) : void
125
127
{
@@ -167,6 +169,10 @@ public static function loadAnnotationClass(string $class) : bool
167
169
}
168
170
}
169
171
172
+ if (self ::$ loaders === [] && self ::$ autoloadNamespaces === [] && self ::$ registerFileUsed === false && \class_exists ($ class )) {
173
+ return true ;
174
+ }
175
+
170
176
self ::$ failedToAutoload [$ class ] = null ;
171
177
172
178
return false ;
0 commit comments