Splits class name to namespace and class name

@param string $class
@return array
193759
public static function splitName($class)
    {
        $pos = strrpos($class, '\\');
        if ($pos === false) {
            return [null, $class];
        } else {
            return [substr($class, 0, $pos), substr($class, $pos+1)];
        }
    }
69637
public function getClassPath($class)
    {
        $segments          = explode('_', $class);
        $namespaceTopLevel = $this->getNamespace();
        $namespace         = '';

        if (!empty($namespaceTopLevel)) {
            $namespace = array();
            $topLevelSegments = count(explode('_', $namespaceTopLevel));
            for ($i = 0; $i < $topLevelSegments; $i++) {
                $namespace[] = array_shift($segments);
            }
            $namespace = implode('_', $namespace);
            if ($namespace != $namespaceTopLevel) {
                // wrong prefix? we're done
                return false;
            }
        }

        if (count($segments) < 2) {
            // assumes all resources have a component and class name, minimum
            return false;
        }

        $final     = array_pop($segments);
        $component = $namespace;
        $lastMatch = false;
        do {
            $segment    = array_shift($segments);
            $component .= empty($component) ? $segment : '_' . $segment;
            if (isset($this->_components[$component])) {
                $lastMatch = $component;
            }
        } while (count($segments));

        if (!$lastMatch) {
            return false;
        }

        $final = substr($class, strlen($lastMatch) + 1);
        $path = $this->_components[$lastMatch];
        $classPath = $path . '/' . str_replace('_', '/', $final) . '.php';

        if (Zend_Loader::isReadable($classPath)) {
            return $classPath;
        }

        return false;
    }
602565
public function extractName($class)
    {
        foreach ($this->extractors as $extractor) {
            if ($extractor->canExtractName($class)) {
                return $extractor->extractName($class);
            }
        }

        throw new \InvalidArgumentException();
    }
615509
public function toClassPath($class)
    {
        $parts = explode(self::ROUTE_SYNTAX_DELIMITER, $class);

        $module = $parts[0];
        unset($parts[0]);

        $path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts));

        return $path;
    }
271333
public function loadClass($className)
    {
        foreach ($this->namespaces as $namespace => $path) {
            if (null === $namespace || $namespace === substr($className, 0, strlen($namespace))) {
                $fileName = '';
                $namespace = '';

                if (false !== ($lastNsPos = strripos($className, $this->namespaceSeparator))) {
                    $namespace = substr($className, 0, $lastNsPos);
                    $className = substr($className, $lastNsPos + 1);
                    $fileName = str_replace(
                        $this->namespaceSeparator,
                        DIRECTORY_SEPARATOR,
                        $namespace
                    ) . DIRECTORY_SEPARATOR;
                }

                $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->fileExtension;

                $this->requireFile(($path !== null ? $path . DIRECTORY_SEPARATOR : '') . $fileName);

                break;
            }
        }

        return $this;
    }
744079
private static function getProperties($class): array
    {
        $reflect = new \ReflectionClass($class);
        $prop = $reflect->getProperties(
            \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE
        );
        $properties = [];
        foreach ($prop as $property) {
            $properties[] = $property->name;
        }
        $parent = \get_parent_class($class);
        if ($parent) {
            $properties = \array_merge(self::getProperties($parent), $properties);
        }
        return $properties;
    }
282101
public function findExtends($class) {
        $this->init();

        $fullQualifiedNamespace = $this->trimNamespace($class);

        $phpClasses = [];

        foreach ($this->localCache as $phpClass) {
            if ($fullQualifiedNamespace === $phpClass->getExtends()) {
                $phpClasses[] = $phpClass;
                $phpClasses   = array_merge($phpClasses, $this->findExtends($phpClass->getFullQualifiedNamespace()));
            }
        }

        return $this->arrayUniqueObject($phpClasses);
    }
1301995
protected function _getClassName($class)
    {
        $class = Str::low($class);
        list ($plugin, $className) = pluginSplit($class);
        $return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX;
        if ($plugin !== null) {
            return Inflector::camelize($plugin) . '\\' . $return;
        }

        return Configure::read('App.namespace') . '\\' . $return;
    }
604299
public function autoload( $class ) {

		// Iterate over namespaces to find a match.
		foreach ( $this->namespaces as $namespace ) {

			// Move on if the object does not belong to the current namespace.
			if ( 0 !== strpos( $class, $namespace['root'] ) ) {
				continue;
			}

			// Remove namespace root level to correspond with root filesystem, and
			// replace the namespace separator "\" by the system-dependent directory separator.
			$filename = str_replace(
				array( $namespace['root'], '\\' ),
				array( '', DIRECTORY_SEPARATOR ),
				$class
			);

			// Remove a leading backslash from the class name.
			$filename = $this->remove_leading_backslash( $filename );

			// Change to lower case if requested.
			if ( $namespace['lowercase'] ) {
				$filename = strtolower( $filename );
			}

			// Change underscores into hyphens if requested.
			if ( $namespace['underscores'] ) {
				$filename = str_replace( '_', '-', $filename );
			}

			// Add base_dir, prefix and suffix.
			$filepath = $namespace['base_dir']
				. $namespace['prefix']
				. $filename
				. $namespace['suffix'];

			// Throw an exception if the file does not exist or is not readable.
			if ( is_readable( $filepath ) ) {
				require_once $filepath;
			}
		}
	}
956583
public function loadClass( $class ) {

		//make sure the class name is absolute
		if ( 0 !== strpos( $class, '\\' ) )
			$class = '\\' . $class;

		// check if the namespace matches the class
		if ( 0 !== strpos( $class, $this->base_ns ) )
			return FALSE;

		// strip the base namespace from the beginning of the class name
		if ( $this->base_ns === substr( $class, 0, strlen( $this->base_ns ) ) )
			$class = substr( $class, strlen( $this->base_ns ) );

		$class = ltrim( $class, '\\' );
		$class = str_replace( '\\', '/', $class );
		$file = $this->base_dir . '/' . $class . '.php';

		return $this->file_loader->loadFile( $file );
	}
1202674
private function parseFullClassName($fullName)
    {
        $parts = explode("\\", $fullName);
        $name = array_pop($parts);
        $namespace = implode("\\", $parts);
        return [$name, $namespace];
    }
910462
public function convertToNamespaceAndClass ($table)
	{
		
		$arr		= explode ('_', $table);
		
		foreach ($arr as &$val)
		{
			$val = ucfirst (strtolower ($val));
		}
		
		array_unshift ($arr, 'Sonic', 'Model');
		
		$class		= array_pop ($arr);
		$namespace	= implode ('\\', $arr);
		
		return array ($namespace, $class);
		
	}
1188050
private function getBundleForClass($class)
    {
        $reflectionClass = new \ReflectionClass($class);
        $bundles = $this->kernel->getBundles();

        do {
            $namespace = $reflectionClass->getNamespaceName();
            foreach ($bundles as $bundle) {
                if ('Symfony\Bundle\FrameworkBundle' === $bundle->getNamespace()) {
                    continue;
                }
                if (0 === strpos($namespace, $bundle->getNamespace())) {
                    return preg_replace('/Bundle$/', '', $bundle->getName());
                }
            }
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);
    }
440773
public static function loadClass($class) {
    	
        //The current namespace prefix
        $prefix = $class;

        //Work backwards through the namespace names of the fully-qualified class name to find a mapped file name
        while(false !== $pos = strrpos($prefix, '\\')) {

            //Retain the trailing namespace separator in the prefix
            $prefix = substr($class, 0, $pos + 1);

            //The rest is the relative class name
            $relative_class = substr($class, $pos + 1);

            //Try to load a mapped file for the prefix and relative class
            $mapped_file = static :: loadMappedFile($prefix, $relative_class);

            if(false !== $mapped_file) {
                return $mapped_file;
            }

            //Remove the trailing namespace separator for the next iteration of strrpos()
            $prefix = rtrim($prefix, '\\');
        }

        //Never found a mapped file
        return false;
    }
239001
public function getTypesForClass(string $class): array
    {
        $types = array_filter(
            $this->typeMap,
            function ($val) use ($class) {
                return $val === $class;
            }
        );

        if (empty($types)) {
            $error = sprintf('Does not exist any valid type for class "%s"', $class);
            throw new \UnexpectedValueException($error);
        }

        return array_keys($types);
    }
1176882
public function getNamespace($class_name)
	{
		$class_name = trim($class_name, '\\');
		if ($last_separator = strrpos($class_name, '\\'))
		{
			return substr($class_name, 0, $last_separator + 1);
		}
		return '';
	}
434589
private function getAnnotations($class)
    {
        $parsed = $this->getParser()->parse($class);
        if (!is_array($parsed)) {
            return [];
        }
        $context = [
            'class' => $class,
            'declaringClass' => $class,
            'type' => Context::TYPE_CLASS,
            'name' => $class
        ];
        $annotations = [];
        if (!empty($parsed['class'])) {
            foreach ($parsed['class'] as $value) {
                $anno = $this->create($value, $context);
                if ($anno) {
                    $annotations[] = $anno;
                }
            }
        }
        $map = [
            'methods' => Context::TYPE_METHOD,
            'properties' => Context::TYPE_PROPERTY
        ];
        $reflection = new \ReflectionClass($class);
        foreach ($map as $type_name => $type) {
            if (!empty($parsed[$type_name])) {
                foreach ($parsed[$type_name] as $name => $values) {
                    $reflType = $type == 'method' ? $reflection->getMethod($name)
                               : $reflection->getProperty($name);
                    $context['type'] = $type;
                    $context['name'] = $name;
                    $context['declaringClass'] = $reflType->getDeclaringClass()->getName();
                    foreach ($values as $value) {
                        $anno = $this->create($value, $context);
                        if ($anno) {
                            $annotations[] = $anno;
                        }
                    }
                }
            }
        }
        return $annotations;
    }