Return a map of sub-namespaces and their corresponding classes including metadata

@param array $classMap

@return array
965863
protected function getUnifiedNamespaceArray(array $classMap)
    {
        $unifiedNameSpace = [];

        foreach ($classMap as $fullyQualifiedUnifiedClass => $editionClassDescription) {
            $parts = explode('\\', $fullyQualifiedUnifiedClass);
            $shortUnifiedClassName = array_pop($parts);
            $this->validateShortUnifiedClassName($shortUnifiedClassName, $fullyQualifiedUnifiedClass);

            $unifiedSubNamespace = implode('\\', $parts);
            $this->validateUnifiedNamespace($unifiedSubNamespace, $fullyQualifiedUnifiedClass);

            $this->validateEditionClassDescription($editionClassDescription);
            $unifiedNameSpace[$unifiedSubNamespace][] = [
                // Interfaces are abstract for Reflection too, here we want just abstract classes
                'isAbstract'            => $editionClassDescription['isAbstract'],
                'isInterface'           => $editionClassDescription['isInterface'],
                'isDeprecated'          => $editionClassDescription['isDeprecated'],
                'shortUnifiedClassName' => $shortUnifiedClassName,
                'editionClassName'      => $editionClassDescription['editionClassName'],
            ];
        }

        return $unifiedNameSpace;
    }
1344935
public function load_theme($classmap = null)
    {
        if ($classmap !== null) {
            static::$theme_includes = \unserialize($classmap);
        } else {
            $hookables_dir = \trim(Config::get('theme.hookables_directory'), '/');
            $root = \trailingslashit(\get_template_directory());

            $hookable_locations = [
                $root . 'theme/' . $hookables_dir,
                $root . 'theme/Http/Ajax',
                $root . 'theme/Http/Middleware',
                $root . 'theme/Http/Validation/Rules',
                $root . 'theme/Content',
                $root . 'theme/Events',
            ];

            if (\is_child_theme()) {
                $root = \trailingslashit(\get_stylesheet_directory());

                $hookable_locations[] = $root . 'theme/' . $hookables_dir;
                $hookable_locations[] = $root . 'theme/Http/Ajax';
                $hookable_locations[] = $root . 'theme/Http/Middleware';
                $hookable_locations[] = $root . 'theme/Http/Validation/Rules';
                $hookable_locations[] = $root . 'theme/Content';
                $hookable_locations[] = $root . 'theme/Events';
            }

            // Gather all possible Hookables.
            foreach ($hookable_locations as $dir) {
                static::$theme_includes = $this->scan_dir($dir, static::$theme_includes);
            }

            if (!empty(static::$theme_includes)) {
                foreach (static::$theme_includes as $class => $path) {
                    $this->init_hookable($class);
                }
            }

            static::$theme_includes = $this->scan_dir(
                \get_stylesheet_directory() . '/theme/',
                static::$theme_includes
            );
        }

        $this->init_theme_providers();
        $this->init_theme_setup();
    }
1256653
public function registerObjects($classmap)
    {
        foreach ($classmap as $service => $file) {
            $this->add($service);
            $component = $this->get($service);
        }
    }
70878
public static function getMappedClassName($className)
    {
        $mappedName = array_search($className, self::$classMap);

        if ($mappedName) {
            return $mappedName;
        }

        $mappedName = array_search($className, array_flip(self::$classMap));

        if ($mappedName) {
            return $mappedName;
        }

        return false;
    }
155611
private function getClassNameCandidates(array $namespaces, $name)
    {
        $className = str_replace(' ', '', ucwords($name));

        return array_map(function ($namespace) use ($className) { return $namespace.$className; }, $namespaces);
    }
857009
public static function add_namespace_to_class_map_entries( $map_entries, $classname )
	{
		if ( is_string( $map_entries ) && ! empty( $map_entries ) )
		{
			$map_entries = array( $map_entries );
		}

		if ( ! is_array( $map_entries ) || count( $map_entries ) === 0 ) return;

		XBRL::$namespace_to_class_map = array_merge( XBRL::$namespace_to_class_map, array_fill_keys( $map_entries, $classname ) );
	}
295509
public static function buildTree(array $aliasMemberMap) : array
    {
        InvalidArgumentException::verifyAllInstanceOf(__METHOD__, 'aliasMemberMap', $aliasMemberMap, NestedMember::class);

        $arrayTree     = [];
        $hashMemberMap = [];

        foreach ($aliasMemberMap as $alias => $nestedMember) {
            $currentMemberHash = '';
            $currentNode       =& $arrayTree;

            foreach ($nestedMember->getParts() as $part) {
                $memberString = $part->asString();
                $currentMemberHash .= '||' . $memberString;

                $currentNode =& $currentNode[$memberString];
                $hashMemberMap[$currentMemberHash] = $part;
            }

            $currentNode[] = $alias;
        }

        return self::buildMemberNodeFromTree('', $arrayTree, $hashMemberMap);
    }
231104
public function getMappingByClassName(string $className) : Mapping
    {
        $className = ltrim($className, '\\');

        return (!empty($this->mappings[$className])) ? $this->mappings[$className] : Mapping::null();
    }
805595
protected function getApiMapping($className)
    {
        $apiMapping = Config::inst()->get($className, 'api_field_mapping');
        if ($apiMapping && is_array($apiMapping)) {
            return $apiMapping;
        }
        return [];
    }
1021425
public static function extractNamespaces(ClassLoader $classLoader) {
    $namespaces = [];
    foreach ($classLoader->getPrefixes() as $namespace => $directories) {
      $namespaces[$namespace] = $directories[0];
    }
    foreach ($classLoader->getPrefixesPsr4() as $namespace => $directories) {
      $namespaces[$namespace] = $directories[0];
    }
    return new \ArrayIterator($namespaces);
  }
667454
public function addClassMap(array $map)
    {
        if (empty($this->classMap)) {
            $this->classMap = $map;

            return $this;
        }
        $this->classMap = array_merge($this->classMap, $map);

        return $this;
    }
1118845
public function getMetadataFor($className)
    {
        $metadata = parent::getMetadataFor($className);
        if ($metadata) {
            return $metadata;
        }

        throw MappingException::classNotMapped($className);
    }
1273178
public function renameClasses(array $classMap, array $options)
    {
        $options += ['class' => []];
        $options['class'] = $this->_toClassArray($options['class']);
        $classes = [];
        foreach ($options['class'] as $name) {
            $classes[] = array_key_exists($name, $classMap)
                ? $classMap[$name]
                : $name;
        }
        $options['class'] = trim(implode(' ', $classes));

        return $options;
    }
423443
public function entities($entityClassMapperClassMap)
    {
        foreach ($entityClassMapperClassMap as $entity => $mapper) {
            $this->entity($entity)->from($mapper);
        }
    }
1174976
protected function getClassMappingConfiguration($className)
    {
        if (array_key_exists($className, $this->mappings)) {
            return [
                'className' => $className,
                'mapping' => $this->mappings[$className],
            ];
        }

        $reflection = new \ReflectionClass($className);
        while ($reflection = $reflection->getParentClass()) {
            if (array_key_exists($reflection->getName(), $this->mappings)) {
                return [
                    'className' => $reflection->getName(),
                    'mapping' => $this->mappings[$reflection->getName()],
                ];
            }
        }

        throw new MissingClassMappingConfigurationException($className, array_keys($this->mappings));
    }
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 );
	}
1361387
public function getClassMap()
    {
        $unifiedNamespaceClassMapOfProfessionalEdition = parent::getClassMap();

        $enterpriseEditionRootPath = $this->facts->getEnterpriseEditionRootPath();
        $unifiedNamespaceClassMapOfEnterpriseEdition = $this->resolveUnifiedNamespaceClassMap($enterpriseEditionRootPath);

        return array_merge($unifiedNamespaceClassMapOfProfessionalEdition, $unifiedNamespaceClassMapOfEnterpriseEdition);
    }