Returns correct class file header.

@param string $className The name of the class withing the file
@return string
326023
protected function _classFileHeader($className)
    {
        $header = <<<TEXT
<?php
/**
 * Licensed under The GPL-3.0 License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @since    2.0.0
 * @author   Christopher Castro <chris@quickapps.es>
 * @link     http://www.quickappscms.org
 * @license  http://opensource.org/licenses/gpl-3.0.html GPL-3.0 License
 */

TEXT;

        if ($this->params['fixture']) {
            $header .= <<<TEXT
namespace CMS\Test\Fixture;

use Cake\TestSuite\Fixture\TestFixture;


TEXT;
        }

        $header .= $this->params['fixture'] ? "class {$className} extends TestFixture\n" : "\nclass {$className}\n";

        return $header;
    }
369549
public function findClassName($className)
    {
        if (!empty($this->lookupCache->classes[$className])) {
            return $this->lookupCache->classes[$className];
        }

        if (class_exists($className)) return $className;
        $startsWithSlash = ($className[0] == '\\');

        foreach ($this->searchOrder as $namespace)
        {
            $testClass = '\\' . $namespace;
            if (!$startsWithSlash) {
                $testClass .= '\\';
            }

            $testClass .= $className;

            if (class_exists($testClass)) {
                $this->lookupCache->classes[$className] = $testClass;
                return $testClass;
            }
        }

        return null;
    }
996352
public function loadClass($className)
    {
        $fileName = "";
        if (false !== ($lastNsPos = strripos($className, self::NAMESPACE_SEPARATOR))) {
            $namespace = substr($className, 0, $lastNsPos);
            $className = substr($className, $lastNsPos + 1);
            $fileName = str_replace(self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
        }
        $fileName .= str_replace("_", DIRECTORY_SEPARATOR, $className) . self::FILE_EXTENSION;

        foreach ($this->paths as $path) {
            $filePath = $path . DIRECTORY_SEPARATOR . $fileName;
            if (file_exists($filePath)) {
                require_once $filePath;
            }
        }
    }
80489
private function getRealClassName(string $className): string
    {
        // __CG__: Doctrine Common Marker for Proxy (ODM < 2.0 and ORM < 3.0)
        // __PM__: Ocramius Proxy Manager (ODM >= 2.0)
        if ((false === $positionCg = strrpos($className, '\\__CG__\\')) &&
            (false === $positionPm = strrpos($className, '\\__PM__\\'))) {
            return $className;
        }

        if (false !== $positionCg) {
            return substr($className, $positionCg + 8);
        }

        $className = ltrim($className, '\\');

        return substr(
            $className,
            8 + $positionPm,
            strrpos($className, '\\') - ($positionPm + 8)
        );
    }
889375
public function loadClass($className) {
        $classFound = $this->composerClassLoader->loadClass($className);
        if (!$classFound && !$this->caseSensitiveClassLoading) {
            $classFound = $this->composerClassLoader->loadClass(strtolower($className));
        }
        return $classFound;
    }
1026328
protected function fileNameforClass(string $className, string $type = 'main'): string
    {
        if (file_exists($this->rootpath->to('composer.json'))) {
            $composer = json_decode(
                    file_get_contents($this->rootpath->to('composer.json')),
                    true
            );
            if (isset($composer['autoload']['psr-4'])) {
                return $this->fileNameForPsr4(
                        $composer['autoload']['psr-4'],
                        $className,
                        $type
                );
            }
        }

        // assume psr-0 with standard stubbles pathes
        return $this->rootpath->to(
                'src',
                $type,
                'php',
                str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php'
        );
    }
1258433
public function classname_to_path( $classname ) {
		// Convert the namespace to a sub-directory path
		if ( strpos( $classname, '\\' ) !== false) {
			$classname = str_replace( '\\', DIRECTORY_SEPARATOR, $classname );
		}

		return $classname;
	}
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;
    }
370571
public function load($className)
    {
        $this->_classFilename = $className . '.php';
        $this->_includePaths  = explode(PATH_SEPARATOR, get_include_path());
        $classFound           = null;

        if(strpos($this->_classFilename, '\\') !== false)
        {
            $classFound = $this->searchForBackslashNamespacedClass();
        }
        elseif(strpos($this->_classFilename, '_') !== false)
        {
            $classFound = $this->searchForUnderscoreNamespacedClass();
        }
        else
        {
            $classFound = $this->searchForNonNamespacedClass();
        }

        return $classFound;
    }
471943
private function getDocCommentFromFile($fileName)
    {
        $lines = file($fileName, FILE_IGNORE_NEW_LINES);

        $declaringClassStartLine = $this->getDeclaringClass()->getStartLine() - 1;
        $declaringClassLength = $this->getDeclaringClass()->getEndLine() - $declaringClassStartLine + 1;

        $currentClassLines = array_slice($lines, $declaringClassStartLine, $declaringClassLength, true);

        // Need the php open tag to tokenize the class.
        $tokens = token_get_all("<?php\n" . implode("\n", $currentClassLines));

        $return = false;
        $constDeclarationKey = $this->getCurrentConstantKeyFromClassTokens($tokens);

        // Now we have the key value of the constant declaration, we have to pick up the comment before the declaration (if it exists).
        for ($constDeclarationKey--; $constDeclarationKey > 0; $constDeclarationKey--) {
            if ($tokens[$constDeclarationKey][0] !== T_WHITESPACE && $tokens[$constDeclarationKey][0] !== T_DOC_COMMENT) {
                break;
            } elseif ($tokens[$constDeclarationKey][0] === T_DOC_COMMENT) {
                $return = $tokens[$constDeclarationKey][1];
                break;
            }
        }

        return $return;
    }
810365
public function getModuleByClassName($className)
    {
        $longest = 0;
        $foundModule = false;
        
        $className = Framework::prepareClassName($className);
        
        foreach ($this->modules as $moduleNamespace => $module) {
            $moduleNamespace = Framework::prepareNamespace($moduleNamespace);
            $sameNamespace = strpos($className, $moduleNamespace);
            $length = strlen($moduleNamespace);

            if ($sameNamespace !== false && $length > $longest) {
                $longest = $length;
                $foundModule = $module;
            }
        }
        
        return $foundModule;
    }
1113030
public function loadClass($className)
    {
        $found = false;
        $nsSep = $this->namespace.$this->namespaceSeparator;
        if (null === $this->namespace || $nsSep === substr($className, 0, strlen($nsSep))) {
            $fileName = '';
            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);
                $fileName .= DIRECTORY_SEPARATOR;
            }
            $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->fileExtension;
            $filePath  = stream_resolve_include_path($this->includePath . DIRECTORY_SEPARATOR . $fileName);
            if ($filePath) {
                /** @noinspection PhpIncludeInspection */
                require $filePath;
                $found = true;
            }
        }
        return $found;
    }
973140
public function loadClass($className)
    {
        if (self::typeExists($className)) {
            return true;
        }

        if ( ! $this->canLoadClass($className)) {
            return false;
        }

        require($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
               . str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className)
               . $this->fileExtension;

        return self::typeExists($className);
    }
1161875
public static function getClassFromFileName($filename)
    {
        $filename = basename($filename);

        $rpos = strrpos($filename, '.');

        if ($rpos != -1) {
            $filename = substr($filename, 0, $rpos);
        }

        return $filename;
    }
1098201
public function getPathForFutureClass(string $className)
    {
        $classLoader = $this->getClassLoader();

        // lookup is obviously modeled off of Composer's autoload logic
        foreach ($classLoader->getPrefixesPsr4() as $prefix => $paths) {
            if (0 === strpos($className, $prefix)) {
                return $paths[0].'/'.str_replace('\\', '/', substr($className, \strlen($prefix))).'.php';
            }
        }

        foreach ($classLoader->getPrefixes() as $prefix => $paths) {
            if (0 === strpos($className, $prefix)) {
                return $paths[0].'/'.str_replace('\\', '/', $className).'.php';
            }
        }

        if ($classLoader->getFallbackDirsPsr4()) {
            return $classLoader->getFallbackDirsPsr4()[0].'/'.str_replace('\\', '/', $className).'.php';
        }

        if ($classLoader->getFallbackDirs()) {
            return $classLoader->getFallbackDirs()[0].'/'.str_replace('\\', '/', $className).'.php';
        }

        return null;
    }
1201827
private function getClassName(string $filename, array $previousDeclaredClasses)
    {
        $filename = realpath($filename);
        $classes = get_declared_classes();
        $newClasses = array_values(array_diff($classes, $previousDeclaredClasses));

        $className = $this->_searchForUnitTestClass($newClasses, $filename);
        if (isset($className)) {
            return $className;
        }

        $className = $this->_searchForUnitTestClass($classes, $filename);
        if (isset($className)) {
            return $className;
        }
    }
449461
public function fullyQualifiedClassName($className)
    {
        if ($className !== null && strpos($className, '\\') === false && strlen($this->namespace) > 0) {
            return $this->namespace.'\\'.$className;
        }

        return $className;
    }