@param  string|null $namespace_name

@return array<string, string>
762908
public function getAliasedClassesFlipped($namespace_name = null)
    {
        if ($namespace_name && isset($this->namespace_aliased_classes_flipped[$namespace_name])) {
            return $this->namespace_aliased_classes_flipped[$namespace_name];
        }

        return $this->aliased_classes_flipped;
    }
816865
public function getRootNamespace()
    {
        if (($psr4 = $this->get('autoload.psr-4')) === null) {
            return null;
        }

        foreach ($psr4 as $namespace => $namespacePaths) {
            foreach ((array)$namespacePaths as $namespacePath) {
                // The namespace path should be a subdirectory of the "src" directory
                if (mb_strpos(realpath($this->rootPath . '/' . $namespacePath), realpath($this->psr4RootPath)) === 0) {
                    return rtrim($namespace, '\\');
                }
            }
        }

        return null;
    }
1326943
static public function findClass($name, $type=null, $namespaces=null)
	{
	    $name = StringHelper::toClassName($name);
	    if (!$namespaces && strpos($name, '\\') !== false && class_exists($name)) {
	        return $name;
	    }
	    
	    $class_names = [];
	    if (!empty($type)) {
	        $type = StringHelper::toCamelCase($type);
	        if ($pos = strpos($name, '\\')) {
	            $class_names[] = $type . '\\' . $name . $type;
	            $class_names[] = $type . '\\' . $name;
	            
	            $name = substr($name, 0, $pos) . '\\' . $type . '\\' . substr($name, $pos+1);
	        } else {
	            $name = $type . '\\' . $name;
	        }
	        $class_names[] = $name;
	        $class_names[] = $name . $type;
		} else {
		    $class_names[] = $name;
		}
		
		if ($namespaces) {
            $namespaces = (array)static::formatNamespace($namespaces);
		} else {
            //$namespaces = array_unique(array_merge((array)$namespaces, static::getNamespaces()));
		    $namespaces = static::getNamespaces();
		}
		
		foreach ($namespaces as $nss) {
		    foreach ($class_names as $class) { 
		        if (class_exists($nss . $class)) {
		            return $nss . $class;
		        }
		    }
		}
		
		return null;
	}
114387
final public function getNamespace(): string
    {
        if (null === $this->namespace) {
            $pos             = strrpos(static::class, '\\');
            $this->namespace = false === $pos ? '' : substr(static::class, 0, $pos);
        }

        return $this->namespace;
    }
279753
public function toPhpString(
        $namespace,
        array $aliased_classes,
        $this_class,
        $php_major_version,
        $php_minor_version
    ) {
        $nullable = false;

        if (!$this->isSingleAndMaybeNullable()
            || $php_major_version < 7
            || (isset($this->types['null']) && $php_minor_version < 1)
        ) {
            return null;
        }

        $types = $this->types;

        if (isset($types['null'])) {
            unset($types['null']);

            $nullable = true;
        }

        if (!$types) {
            return null;
        }

        $atomic_type = array_values($types)[0];

        $atomic_type_string = $atomic_type->toPhpString(
            $namespace,
            $aliased_classes,
            $this_class,
            $php_major_version,
            $php_minor_version
        );

        if ($atomic_type_string) {
            return ($nullable ? '?' : '') . $atomic_type_string;
        }

        return null;
    }
1111138
protected function getNamespaceStatement(File $phpcsFile): array
    {
        $tokens = $phpcsFile->getTokens();

        $namespaceIndex = $phpcsFile->findNext(T_NAMESPACE, 0);
        if (!$namespaceIndex) {
            return [];
        }

        $endIndex = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $namespaceIndex + 1);
        if (!$endIndex) {
            return [];
        }

        $namespace = '';
        $namespaceStartIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $namespaceIndex + 1, null, true);
        $namespaceEndIndex = $phpcsFile->findPrevious(Tokens::$emptyTokens, $endIndex - 1, null, true);
        for ($i = $namespaceStartIndex; $i <= $namespaceEndIndex; $i++) {
            $namespace .= $tokens[$i]['content'];
        }

        return [
            'start' => $namespaceIndex,
            'namespace' => $namespace,
            'end' => $endIndex,
        ];
    }
624625
public function ElementsByNamespaces( $namespaces )
	{
		if ( is_string( $namespaces ) )
			$namespaces = array_map( 'trim', explode( ",", $namespaces ) );

		if ( ! is_array( $namespaces ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );

		$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );

		$instance_namespaces = $this->instance->getInstanceNamespaces();

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( &$elements, $instance_namespaces, $namespaces ) {

			$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
				$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
				return isset( $namespaces[ strtolower( $namespace ) ] );
			} );

			if ( ! $namespaceElements ) return $carry;

			$carry[ $elementName ] = $namespaceElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
560969
protected function getNamespaceFromClassname($class_name)
    {
        $parts = collect(explode('\\', trim($class_name, '\\')));
        $parts->pop();
        return '\\' . $parts->implode('\\');
    }
330427
private function getNamespaces()
    {
      $this->namespaces = array();

      $nodeList = $this->documentElement->getElementsByTagName('*');

      foreach($nodeList as $node)
      {
        if (strlen($node->prefix) && strlen($node->namespaceURI) && !in_array($node->prefix, $this->namespaces))
          $this->namespaces[$node->prefix] = $node->namespaceURI;
      }

      return $this->namespaces;
    }
1302939
protected function _list($name = null)
    {
        if ($name === null) {
            $pluginsList = Plugin::loaded();
        } else {
            if (!Plugin::isLoaded($name)) {
                $this->err(sprintf('Plugin %s is not loaded.', $name));

                return [];
            }
            $pluginsList = [$name];
        }

        $plugins = [];

        foreach ($pluginsList as $plugin) {
            $path = Plugin::path($plugin) . 'webroot';
            if (!is_dir($path)) {
                $this->verbose('', 1);
                $this->verbose(
                    sprintf('Skipping plugin %s. It does not have webroot folder.', $plugin),
                    2
                );
                continue;
            }

            $link = Inflector::underscore($plugin);
            $dir = WWW_ROOT;
            $namespaced = false;
            if (strpos($link, '/') !== false) {
                $namespaced = true;
                $parts = explode('/', $link);
                $link = array_pop($parts);
                $dir = WWW_ROOT . implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
            }

            $plugins[$plugin] = [
                'srcPath' => Plugin::path($plugin) . 'webroot',
                'destDir' => $dir,
                'link' => $link,
                'namespaced' => $namespaced
            ];
        }

        return $plugins;
    }
919689
public function attributesAsArray($namespace = null)
    {
        $attributes = [];

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

        return $attributes;
    }
367742
public static function get(string $name): ?string
    {
        $data = Session::get($name, null, self::$namespace);
        if (is_array($data) && array_key_exists('token', $data)) {
            return $data['token'];
        }
        return null;
    }
257707
static public function getNamespaces($type=null)
	{
	    static::initNamespace();
	    
	    if ($type) {
	        $nss = [];
	        foreach (static::$namespaces as $k => $v) {
	            $nss[$k] = $v . ucfirst($type) . '\\';
	        }
	        return $nss;
	    } else {
	        return static::$namespaces;
	    }
	}
668148
private function getNamespacedIntersectionTypes($namespace, array $aliased_classes, $this_class, $use_phpdoc_format)
    {
        if (!$this->extra_types) {
            return '';
        }

        return '&' . implode(
            '&',
            array_map(
                /**
                 * @param TNamedObject|TTemplateParam|TIterable $extra_type
                 * @return string
                 */
                function (Atomic $extra_type) use (
                    $namespace,
                    $aliased_classes,
                    $this_class,
                    $use_phpdoc_format
                ) {
                    return $extra_type->toNamespacedString(
                        $namespace,
                        $aliased_classes,
                        $this_class,
                        $use_phpdoc_format
                    );
                },
                $this->extra_types
            )
        );
    }
1191883
private function parseName(string $name): array
    {
        $name = str_replace('/', '\\', $name);

        if (strpos($name, '\\') !== false) {
            $names = explode('\\', $name);
            $class = array_pop($names);

            return [join('\\', $names), $class];
        }

        //No user namespace
        return ['', $name];
    }
878307
public function load_class($class_name) {
		foreach ($this->namespaces as $namespace => $namespace_path) {
			$file_path = str_replace(' ', '/', ucwords(str_replace('_', ' ', str_replace('\\', ' ', strtolower($class_name))))) . '.php';
			$path = $namespace_path . '/' . substr($file_path, strpos('/', $file_path));
			try {
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }
		}

		foreach ($this->include_paths as $include_path) {
			$file_path = str_replace(' ', '/', ucwords(str_replace('_', ' ', str_replace('\\', ' ', strtolower(str_replace($include_path['class_prefix'], '', $class_name)))))) . '.php';

			try {
				$path = $include_path['include_path'] . '/' . $file_path;
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }

			/**
			 * If the file is not found, try with all lower case. This should be
			 * improved with PSR loading techniques
			 */
			try {
				$path = strtolower($include_path['include_path'] . '/' . $file_path);
				$this->require_file($path);

				if (class_exists($class_name, false)) {
					class_parents($class_name, true);
					return true;
				}
			} catch (\Exception $e) { }

		}
	}
319513
public function get($name)
	{
		$namespaced = $this->namespace.':'.$name;

		$queued   = $this->length($namespaced, 'list');
		$delayed  = $this->length($namespaced.':delayed', 'zset');
		$reserved = $this->length($namespaced.':reserved', 'zset');

		return array('queued' => $queued, 'delayed' => $delayed, 'reserved' => $reserved);
	}