Set Namespace From Getters
- save current namespace state
- reset getters namespace state
- set namespace to getters

[php]
->system->methods->Introspection(['x'=>1,])
[/php]

@param array $gettersNamespaces Namespaces
@return $this
435658
protected function _setNamespaceFromGetters(array $gettersNamespaces)
    {
        ($this->_c__namespace) ?: $this->_c__namespace = $this->namespace;
        $this->setNamespace($gettersNamespaces);
        $this->namespace_getter = array();

        return $this;
    }
760545
public static function setNamespaces($namespaces)
    {
        $called = get_called_class();

        if (!$namespaces instanceof PriorityQueue) {
            $namespaces = new PriorityQueue();
        }

        static::$namespaces[$called] = $namespaces;
    }
749863
public function register_namespace( $namespace, $paths )
    {
        if ( isset( $this->namespaces[ $namespace ] ) )
        {
            $this->namespaces[ $namespace ] = array_merge(
                $this->namespaces[ $namespace ],
                (array) $paths
            );
        } 
        else 
        {
            $this->namespaces[ $namespace ] = (array) $paths;
            
            // Register PSR_0 as the first autoload filter for every namespace
            $this->register_autoload_filter( $namespace, array( $this, "PSR_0" ) );
        }
    }
1023148
public function attachNamespace($namespace, $paths)
    {
        if (isset($this->namespaces[$namespace])) {
            if (is_array($paths)) {
                $this->namespaces[$namespace] = array_merge($this->namespaces[$namespace], $paths);
            } else {
                $this->namespaces[$namespace][] = $paths;
            }
        } else {
            $this->namespaces[$namespace] = (array) $paths;
        }

        return $this;
    }
1367546
public function addNamespace($namespace, $priority = PriorityQueue::NORMAL)
    {
        $this->controllerResolver->addNamespace($namespace . '\Controller', $priority);
        $this->repositoryResolver->addNamespace($namespace . '\Repository', $priority);
        $this->repositoryResolver->addNamespace($namespace . '\Model', $priority);
        $this->viewResolver->addNamespace($namespace . '\View', $priority);

        return $this;
    }
1073325
public function addNamespaces(array $namespaces)
    {
        foreach ($namespaces as $prefix => $baseDir) {
            $this->addNamespace($prefix, $baseDir);
        }
    }
1145641
public static function getNamespace($tokens)
    {
        $count = count($tokens);
        $i = 0;
        $namespace = '';
        $namespace_ok = false;
        while ($i < $count) {
            $token = $tokens[$i];
            if (is_array($token) && $token[0] === T_NAMESPACE) {
                // Found namespace declaration
                while (++$i < $count) {
                    if ($tokens[$i] === ';') {
                        $namespace_ok = true;
                        $namespace = trim($namespace);
                        break;
                    }
                    $namespace .= is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i];
                }
                break;
            }
            $i++;
        }
        if (!$namespace_ok) {
            return null;
        } else {
            return $namespace;
        }
    }
884387
private function fetchNamespaces (NamespaceRegistry $entryNamespaces) : array
    {
        $namespaces = [];

        foreach ($entryNamespaces as $namespace => $path)
        {
            $namespaces[$namespace] = $this->makePathRelative($path);
        }

        return $namespaces;
    }
1245108
public function setNumSpaces(int $numSpaces): self
    {
        $this->spaces = \str_repeat(' ', $numSpaces);
        $this->numSpaces = $numSpaces;

        return $this;
    }
832073
static public function formatNamespace($namespace)
	{
	    if (is_array($namespace)) {
	        foreach ($namespace as $k => $v) {
	            $namespace[$k] =  static::formatNamespace($v);
	        }
	    } else {
	        $namespace = trim(str_replace('/', '\\', $namespace), '\\') . '\\';
	    }
	    
	    return $namespace;
	}
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 );
	}
513352
public function setOptions(array $options)
    {
        // Set namespace first, see ZF-10836
        if (isset($options['namespace'])) {
            $this->setNamespace($options['namespace']);
            unset($options['namespace']);
        }

        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }
585807
public function setNamespaces($namespaces)
    {
        if (!$namespaces instanceof PriorityQueue) {
            $namespaces = new PriorityQueue($namespaces);
        }

        $this->namespaces = $namespaces;

        return $this;
    }
1089578
static function setCache($namespace)
    {
        $cacheData = [];
        $data = CommonConfigModel::getConfigByNamespace($namespace);
        foreach ($data as $key => $value) {
            $cacheData[$value['name']] = [
                'value'=>self::_getInfo($value['vtype'], $value['value']),
                'issystem'=>$value['issystem'],
                'desc'=>$value['desc']
            ];
        }
        $cacheName = 'config:'.$namespace;
        Cache::forever($cacheName, $cacheData);
        return $cacheData;
    }
1255814
public function setNamespace($namespace)
    {
        if (!is_string($namespace)) {
            throw new \InvalidArgumentException('The attribute namespace on the class Entity has to be string (' . gettype($namespace) . ('object' === gettype($namespace) ? ' ' . get_class($namespace) : '') . ' given).');
        }

        if (strlen($namespace) < 1) {
            throw new \InvalidArgumentException('On the attribute namespace, the length of the string ' . $namespace . ' is ' . strlen($namespace) . ' which is shorter than the minimum allowed (1).');
        }

        $this->namespace = $namespace;

        return $this;
    }
123532
private function extractNamespaces(array $tokens)
    {
        $closureNamespace = null;
        $closureUses = [];
        $state = null;
        $namespace = null;
        $alias = null;
        foreach ($tokens as $token) {
            if (is_array($token)) {
                if ($state === null && ($token[0] === T_NAMESPACE || $token[0] === T_USE)) {
                    $state = $token[0];
                    $namespace = '';
                } elseif ($state === T_USE && $alias === null && $token[0] === T_AS) {
                    $alias = '';
                } elseif ($state !== null && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
                    if ($alias !== null) {
                        $alias .= $token[1];
                    } else {
                        $namespace .= $token[1];
                    }
                }
            } else {
                if ($state !== null && ($token === ';' || $token === '{')) {
                    if ($alias === null) {
                        if ($state === T_NAMESPACE) {
                            $closureNamespace = $namespace;
                            $closureUses = [];
                        } else {
                            $closureUses[] = $namespace;
                        }
                    } else {
                        $closureUses[$alias] = $namespace;
                        $alias = null;
                    }
                    $state = null;
                    $namespace = null;
                } elseif ($state === T_USE && $token === ',') {
                    if ($alias === null) {
                        $closureUses[] = $namespace;
                    } else {
                        $closureUses[$alias] = $namespace;
                        $alias = null;
                    }
                    $namespace = null;
                }
            }
        }
        return [
            'namespace' => $closureNamespace,
            'uses' => $closureUses,
        ];
    }
1348123
public function loadNamespaces()
    {
        $data       = json_decode(file_get_contents(base_path('composer.json')), JSON_OBJECT_AS_ARRAY);
        $namespaces = array_get($data, 'autoload.psr-4');
        $this->setNamespaces($namespaces);
        return $this;
    }