加载模块注解
@param string $namespace
@param callable $callback
@return void
433710
public function loadModuleAnnotations($namespace, $callback)
    {
        $this->enumModulePath($namespace, function($ns, $path) use($callback){
            $pathLength = strlen($path);
            foreach(File::enumPHPFile($path) as $filePath)
            {
                $filePath = $filePath[0];
                $diffPath = substr($filePath, $pathLength);
                if(isset($diffPath[0]) && DIRECTORY_SEPARATOR === $diffPath[0])
                {
                    $diffPath = substr($diffPath, 1);
                }
                $diffPath = dirname($diffPath);
                if('.' === $diffPath)
                {
                    $diffPath = '';
                }
                else
                {
                    $diffPath .= DIRECTORY_SEPARATOR;
                }
                $fileNamespace = $ns . '\\' . str_replace(DIRECTORY_SEPARATOR, '\\', $diffPath . basename($filePath, '.php'));
                // 回调
                call_user_func($callback, $fileNamespace);
            }
        });
    }
689649
public function addNamespace( $prefix, $namespace )
	{
		if ( empty( $namespace ) )
		{
			throw new ArgumentOutOfRangeException( "The $namespace parameter to addNamespace cannot be null or empty" );
		}

		if ( substr( $prefix, 0, 5 ) == "xmlns" )
		{
			$prefix = substr( $prefix, 5 );
		}

		if ( strlen( $prefix ) > 0 && $prefix[0] == ":" )
		{
			$prefix = substr( $prefix, 1 );
		}

		if ( empty( $prefix) && empty( $this->defaultNamespace ) )
		{
			$this->defaultNamespace = $namespace;
		}

		$this->namespaces[ $prefix ] = $namespace;
	}
1239888
public function register_namespace( $namespace = '', $base = '' ) {
		if ( $namespace && is_dir( $base ) ) {
			$base                           = rtrim( $base, DIRECTORY_SEPARATOR );
			$this->namespaces[ $namespace ] = $base;
		}
	}
749297
protected function exportCallback($namespace, callable $callback, $argument)
	{
		if (is_array($callback) && is_string($callback[0]))
		{
			// Replace ['foo', 'bar'] with 'foo::bar'
			$callback = $callback[0] . '::' . $callback[1];
		}

		if (!is_string($callback))
		{
			return 'call_user_func(' . var_export($callback, true) . ', ' . $argument . ')';
		}

		// Ensure that the callback starts with a \
		if ($callback[0] !== '\\')
		{
			$callback = '\\' . $callback;
		}

		// Replace \foo\bar::baz() with bar::baz() if we're in namespace foo
		if (substr($callback, 0, 2 + strlen($namespace)) === '\\' . $namespace . '\\')
		{
			$callback = substr($callback, 2 + strlen($namespace));
		}

		return $callback . '(' . $argument . ')';
	}
800086
final public function initWithArgs($namespace, $modName)
    {
        //只能被框架调用一次，不允许用户调用
        //此处不采用反射实现，是因为已知可以直接传递，减少计算量
        if (empty($namespace) || empty($modName) || $this->namespace) {
            throw new Exception('method deny,invoke:' . __METHOD__ . '@' . get_class($this));
        }

        //初始化模块属性
        $this->namespace = $namespace;
        $this->modName = $modName;

        $this->init();
    }
295342
function loadTasks(string $namespace, $tasks) {
        if (!is_array($tasks))
            $tasks = [$tasks];
        foreach ($tasks as &$task) {
            $class_name = $namespace.$task;
            if (!is_subclass_of($class_name, '\\Acast\\CronService\\TaskInterface')) {
                Console::warning("Invalid class \"$task\".");
                continue;
            }
            $this->addTask($class_name::init());
        }
    }
717393
protected function init($namespace = '', $defaultLifetime = null)
    {
        $this->namespace = (string) $namespace;
        $this->defaultLifetime = $this->convertTtl($defaultLifetime);
        $this->miss = new \stdClass;
    }
126743
public function addCallback($concrete, callable $callback)
    {
        //Strip all leading backslashes
        if ($concrete[0] === '\\') {
            $concrete = substr($concrete, 1);
        }

        if (!isset($this->callbacks[$concrete])) {
            $this->callbacks[$concrete] = [];
        }
        $this->callbacks[$concrete][] = $callback;
    }
198937
protected function _addNamespaces($names, array $namespaces, array &$logs = array())
    {
        if (!is_array($names)) {
            $names = array($names);
        }
        $return_names = array();
        foreach ($names as $_name) {
            foreach ($namespaces as $_namespace) {
                if (CodeHelper::namespaceExists($_namespace)) {
                    $tmp_namespace = rtrim(TextHelper::toCamelCase($_namespace), '\\').'\\';
                    $return_names[] = $tmp_namespace.str_replace($tmp_namespace, '', TextHelper::toCamelCase($_name));
                } else {
                    $logs[] = $this->_getErrorMessage('Namespace "%s" not found!', $_namespace);
                }
            }
        }
        return $return_names;
    }
495460
public function changeNamespace(string $namespace): void
	{
		$this->setNamespace($namespace);
		$result = $this->getStorage()->fetchAll();
		foreach ($result as $row) {
			$resource = $this->imageStorage->getResource($row->name);
			$resource->setNamespace($this->namespace);
			$this->imageStorage->save($resource);

			$this->getStorage()->update($row->key, $resource->getIdentifier());
		}
	}
695029
public function register($namespace=null, $path = null, $psr4=false)
    {
        $this->load_ns[$namespace] = array($path, $psr4);
        if ($this->registered) { 
            return;
        }
        spl_autoload_register(array($this,"spl_autoload_callback"));
        $this->registered = true;
    }
101181
public function addPath(string $path, string $namespace = null): void
    {
        $namespace = $namespace ?: FileViewFinder::DEFAULT_NAMESPACE;
        $this->finder->addPath($path, $namespace);
    }
213117
public function addOnFulfilled(callable $callback): void
    {
        if ($this->getState() === Promise::PENDING) {
            $this->onFulfilled[] = $callback;
        } elseif ($this->getState() === Promise::FULFILLED) {
            $response = call_user_func($callback, $this->responseBuilder->getResponse());
            if ($response instanceof ResponseInterface) {
                $this->responseBuilder->setResponse($response);
            }
        }
    }
1365714
public function addPath(string $path, string $namespace = self::DEFAULT_NAMESPACE)
    {
        // invalidate the cache
        $this->cache = $this->errorCache = [];

        $this->paths[$namespace][] = rtrim($path, '/\\');
    }
85169
protected function convertCallbackToClosure($callback, $namespace)
    {
        if ($callback instanceof Closure || is_callable($callback)) {
            return $callback;
        } elseif (is_string($callback)) {
            $namespace = rtrim($namespace, '\\').'\\';
            $arrCallback = explode('::', $callback);
            $isStaticCall = count($arrCallback) == 2;
            if ($isStaticCall) {
                $className = $namespace.$arrCallback[0];
                return [$className, $arrCallback[1]];
            } else {
                $arrCallback = explode(':', $callback);
                $className = $namespace.$arrCallback[0];
                // Must be replaced with a safer way to instantiate an object
                $obj = $this->container->get($className);
                return [$obj, $arrCallback[1]];
            }
        }
    }
399327
public void add(Namespace namespace) {
		if (has(namespace)) {
			get(namespace.getNamespace()).addPaths(namespace.getPaths());
		} else {
			namespace.addPropertyChangeListener(listener);
			set(namespace.getNamespace(), namespace);
		}
	}
391844
public function attachCallback($channel, $callback)
    {
        $callbackName = $this->getPrefixKeys().$channel;

        $this->assertCallback($callback);
        $this->callbacks[$callbackName] = $callback;
        $this->pubsub->subscribe($channel);
    }