Skip to content

Commit

Permalink
#135 deprecating most of the AnnotationRegistry API, which should j…
Browse files Browse the repository at this point in the history
…ust be using the internal autoloader
  • Loading branch information
Ocramius committed Jul 22, 2017
1 parent 17e4de9 commit c3ec01e
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions lib/Doctrine/Common/Annotations/AnnotationRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public static function reset()
/**
* Registers file.
*
* @param string $file
*
* @return void
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
* autoloading should be deferred to the globally registered autoloader by then. For now,
* use @example AnnotationRegistry::registerLoader('class_exists')
*/
public static function registerFile($file)
public static function registerFile(string $file) : void
{
require_once $file;
}
Expand All @@ -80,9 +80,11 @@ public static function registerFile($file)
* @param string $namespace
* @param string|array|null $dirs
*
* @return void
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
* autoloading should be deferred to the globally registered autoloader by then. For now,
* use @example AnnotationRegistry::registerLoader('class_exists')
*/
public static function registerAutoloadNamespace($namespace, $dirs = null)
public static function registerAutoloadNamespace(string $namespace, $dirs = null) : void
{
self::$autoloadNamespaces[$namespace] = $dirs;
}
Expand All @@ -92,11 +94,13 @@ public static function registerAutoloadNamespace($namespace, $dirs = null)
*
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
*
* @param array $namespaces
* @param string[][]|string[]|null[] $namespaces indexed by namespace name
*
* @return void
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
* autoloading should be deferred to the globally registered autoloader by then. For now,
* use @example AnnotationRegistry::registerLoader('class_exists')
*/
public static function registerAutoloadNamespaces(array $namespaces)
public static function registerAutoloadNamespaces(array $namespaces) : void
{
self::$autoloadNamespaces = \array_merge(self::$autoloadNamespaces, $namespaces);
}
Expand All @@ -107,17 +111,11 @@ public static function registerAutoloadNamespaces(array $namespaces)
* NOTE: These class loaders HAVE to be silent when a class was not found!
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
*
* @param callable $callable
*
* @return void
*
* @throws \InvalidArgumentException
*
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
* autoloading should be deferred to the globally registered autoloader by then. For now,
* use @example AnnotationRegistry::registerLoader('class_exists')
*/
public static function registerLoader(callable $callable)
public static function registerLoader(callable $callable) : void
{
// Reset our static cache now that we have a new loader to work with
self::$failedToAutoload = [];
Expand All @@ -140,6 +138,7 @@ public static function loadAnnotationClass(string $class) : bool
foreach (self::$autoloadNamespaces AS $namespace => $dirs) {
if (\strpos($class, $namespace) === 0) {
$file = \str_replace('\\', \DIRECTORY_SEPARATOR, $class) . '.php';

if ($dirs === null) {
if ($path = stream_resolve_include_path($file)) {
require $path;
Expand Down

0 comments on commit c3ec01e

Please sign in to comment.