Finds the required files for a given 'namespace'. So if I ask for get('app.name')
it would return the full paths to app.php in both the production and specified environments
in an array.

@param   string  $namespace
@return  array
347356
public function getRequiredFiles($namespace)
    {
        $files = [];

        // First loop is finding 'production' config for each basepath:
        foreach ($this->configPaths as $basePath) {
            $configFileCandidate = $basePath.'/'.$namespace.'.php';
            if (file_exists($configFileCandidate)) {
                $files[] = [
                    'path' => realpath($configFileCandidate),
                    'environment' => null
                ];
            }
        }

        // Second loop is finding 'environment level' config for each basepath:
        if ($this->config->getEnvironment() !== null) {
            foreach ($this->configPaths as $basePath) {
                $envConfigFileCandidate = $basePath.'/'.$this->config->getEnvironment().'/'.$namespace.'.php';
                if (file_exists($envConfigFileCandidate)) {
                    $files[] = [
                        'path' => realpath($envConfigFileCandidate),
                        'environment' => $this->config->getEnvironment()
                    ];
                }
            }
        }
        return $files;
    }
1203212
public function getAllCommands(string $namespace = ''): array
	{
		$this->initCommands();

		if ($namespace === '')
		{
			$commands = $this->commands;

			if (!$this->commandLoader)
			{
				return $commands;
			}

			foreach ($this->commandLoader->getNames() as $name)
			{
				if (!isset($commands[$name]))
				{
					$commands[$name] = $this->getCommand($name);
				}
			}

			return $commands;
		}

		$commands = [];

		foreach ($this->commands as $name => $command)
		{
			if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
			{
				$commands[$name] = $command;
			}
		}

		if ($this->commandLoader)
		{
			foreach ($this->commandLoader->getNames() as $name)
			{
				if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
				{
					$commands[$name] = $this->getCommand($name);
				}
			}
		}

		return $commands;
	}
1154700
public function findNamespace(string $namespace): string
	{
		$allNamespaces = $this->getNamespaces();

		$expr = preg_replace_callback(
			'{([^:]+|)}',
			function ($matches)
			{
				return preg_quote($matches[1]) . '[^:]*';
			},
			$namespace
		);

		$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);

		if (empty($namespaces))
		{
			throw new NamespaceNotFoundException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
		}

		$exact = \in_array($namespace, $namespaces, true);

		if (\count($namespaces) > 1 && !$exact)
		{
			throw new NamespaceNotFoundException(sprintf('The namespace "%s" is ambiguous.', $namespace));
		}

		return $exact ? $namespace : reset($namespaces);
	}
362197
public function getModuleConfig(string $namespace) {
		if (array_key_exists($namespace, $this->moduleConfigs)) {
			return $this->moduleConfigs[$namespace];
		}
		
		$module = $this->moduleManager->getModuleByNs($namespace);
		if ($module->hasConfigDescriber()) {
			return $this->moduleConfigs[$namespace] = $module->createConfigDescriber($this)->buildCustomConfig();
		}
		
		return $this->moduleConfigs[$namespace] = null;
	}
919689
public function attributesAsArray($namespace = null)
    {
        $attributes = [];

        foreach ($this->attributes() as $key => $value) {
            $attributes[$key] = $this->getPhpValue((string)$value);
        }

        return $attributes;
    }
585774
private function getByNamespace($namespace)
    {
        $this->checkForNonEmptyNamespace($namespace);

        if (!isset($this->configurations[$namespace])) {
            $this->configurations[$namespace]
                = $this->retrieveConfigurationFromTypoScriptSetup($namespace);
        }

        return $this->configurations[$namespace];
    }
923325
private function getMetadataForNamespace($namespace)
    {
        $metadata = [];
        foreach ($this->getAllMetadata() as $m) {
            if (strpos($m->name, $namespace) !== 0) {
                continue;
            }

            $metadata[] = $m;
        }

        return new ClassMetadataCollection($metadata);
    }
170853
public function load($group, $namespace = null)
    {
        $items = [];

        $path = $this->getPath($namespace);

        if (is_null($path)) {
            return $items;
        }

        $file = "{$path}/{$group}.php";

        if ($this->files->exists($file)) {
            $items = $this->getRequire($file);
        }

        return $items;
    }
1119968
public function getTemplatePath($namespace)
    {
        if (!$this->hasTemplatePath($namespace)) {
            throw new \RuntimeException("Path with namespace \"".$namespace."\" is not exist");
        }

        $path = $this->paths[$namespace];

        if (!is_dir($path)) {
            throw new \RuntimeException("Invalid template path with namespace \"".$namespace."\"");
        }

        return $path;
    }
774839
public function getModuleNameByNamespace($namespace = null)
    {
        $defaultNamespace = 'app';
        $currentRoute = app('router')->getCurrentRoute();

        if (is_null($namespace) and !is_null($currentRoute)) {
            $namespace = $currentRoute->getAction()['namespace'];
        }

        if (is_null($namespace)) {
            return $defaultNamespace;
        }

        foreach ($this->moduleLoader->getRegisteredModules() as $module) {
            if (!empty($moduleNamespace = $module->getNamespace())) {
                if (strpos($namespace, $moduleNamespace) === 0) {
                    return $module->getKey();
                }
            }
        }

        return $defaultNamespace;
    }
229386
protected function findExtensions($namespace)
    {
        $this->initializeNamespaces();
        $files = [];
        $old = [];
        $namespaces = [$namespace, 'Staq\Core\Ground'];
        while (array_diff($namespaces, $old)) {
            $extensions = $this->formatExtensionsFromNamespaces($namespaces);
            foreach ($extensions as $extension) {
                $files[] = $extension . '/setting/Application.ini';
            }
            $ini = (new \Pixel418\Iniliq\IniParser)->parse(array_reverse($files));
            $old = $namespaces;
            $namespaces = array_reverse($ini->getAsArray('extension.list'));
            $namespaces = \UArray::reverseMergeUnique($old, $namespaces);
        }
        return $this->formatExtensionsFromNamespaces($namespaces);
    }
1337211
public static function get($name)
    {
        $namespaces = config('crude.namespace');

        if (! is_array($namespaces)) {
            $fullName = $namespaces . $name;

            return class_exists($fullName)
                ? new $fullName()
                : null;
        }

        foreach ($namespaces as $namespace) {
            $fullName = $namespace . $name;
            if (class_exists($fullName))
                return new $fullName();
        }

        return null;
    }
694477
protected function loadDataForPrefix($namespace, $prefix)
    {
        $this->failOnMissingNamespace($namespace);

        if (!isset($this->cachedData[$namespace])) {
            $this->cachedData[$namespace] = [];
        }

        if (!isset($this->cachedData[$namespace][$prefix])) {
            $this->cachedData[$namespace][$prefix] = [];
        }

        foreach ($this->addedData[$namespace] as $data) {

            if (isset($data[$prefix])) {
                $this->cachedData[$namespace][$prefix][] = $data[$prefix];
            }
        }

        return $this->cachedData[$namespace][$prefix];
    }
507765
protected function getClasses($namespace, $path)
    {
        $classes = [];
        $path = "$path/Console/Command";
        if (!is_dir($path)) {
            return $classes;
        }

        $dir = new \DirectoryIterator($path);
        $classFiles = new \RegexIterator($dir, '/[a-z_]*\.php/i');
        foreach ($classFiles as $file) {
            $classes[] = str_replace('.php', '', "{$namespace}Console\\Command\\{$file}");
        }
        return $classes;
    }
647981
public static function getNamespacePath($namespace)
    {
        if('\\' !== substr($namespace, -1, 1))
        {
            $namespace .= '\\';
        }
        $loader = App::getLoader();
        if(null === $loader)
        {
            // Composer 加载器未赋值，则只能取Main类命名空间下的目录
            foreach(Helper::getMains() as $main)
            {
                $mainNamespace = $main->getNamespace();
                if('\\' !== substr($mainNamespace, -1, 1))
                {
                    $mainNamespace .= '\\';
                }
                $len = strlen($mainNamespace);
                if($mainNamespace === substr($namespace, 0, $len))
                {
                    $namespaceSubPath = substr($namespace, $len);
                    $refClass = new \ReflectionClass($main);
                    $path = dirname($refClass->getFileName());
                    $result = File::path($path, str_replace('\\', DIRECTORY_SEPARATOR, $namespaceSubPath));
                    break;
                }
            }
        }
        else
        {
            // 依靠 Composer PSR-4 配置的目录进行定位目录
            $prefixDirsPsr4 = $loader->getPrefixesPsr4();
            foreach($prefixDirsPsr4 as $keyNamespace => $paths)
            {
                $len = strlen($keyNamespace);
                if(substr($namespace, 0, $len) === $keyNamespace)
                {
                    if(isset($paths[1]))
                    {
                        return null;
                    }
                    $result = File::path($paths[0], str_replace('\\', DIRECTORY_SEPARATOR, substr($namespace, $len)));
                    break;
                }
            }
        }
        if(isset($result))
        {
            $realPath = realpath($result);
            if(false === $realPath)
            {
                return $result;
            }
            else
            {
                return $realPath;
            }
        }
        return null;
    }
559226
public function getAllHashes(string $namespace): array
    {
        $directory = implode(DIRECTORY_SEPARATOR, [
            $this->directory,
            $namespace,
        ]);

        $result = [];
        if (is_dir($directory)) {
            $directoryIterator = new RecursiveDirectoryIterator(
                $directory,
                RecursiveDirectoryIterator::SKIP_DOTS
            );

            foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
                /* @var SplFileInfo $file */
                $result[] = $file->getFilename();
            }
        }
        return $result;
    }
533128
public function lookupPrefix( $namespace )
	{
		foreach ( $this->namespaces as $prefix => $value )
		{
			if ( strcasecmp( $namespace, $value ) === 0 ) return $prefix;
		}

		return false;
	}