/** * Create a class map. * * @param string $subPath The path. * * @param string|null $namespace The namespace prefix (optional). * * @return array */ protected function classMapFromPath($subPath, $namespace = null) { $messages = array(); $classMap = $this->generator->scan($subPath, null, $namespace, $messages); if ($messages) { foreach ($messages as $message) { $this->report->warn(new GenericViolation($message)); } } foreach ($classMap as $class => $file) { try { $this->classMap->add($class, $file); } catch (ClassAlreadyRegisteredException $exception) { $this->report->append(new ClassAddedMoreThanOnceViolation($this->getName(), $class, array($exception->getFileName(), $file))); } } return $classMap; }
* @package phpcq/autoload-validation * @author Christian Schiffler <*****@*****.**> * @copyright 2014-2016 Christian Schiffler <*****@*****.**> * @license https://github.com/phpcq/autoload-validation/blob/master/LICENSE MIT * @link https://github.com/phpcq/autoload-validation * @filesource */ // WARNING!!!! This file is just a reference and should not be used literally. use PhpCodeQuality\AutoloadValidation\ClassLoader\EnumeratingClassLoader; use PhpCodeQuality\AutoloadValidation\ClassMapGenerator; use PhpCodeQuality\AutoloadValidation\Exception\ParentClassNotFoundException; // Support for Contao 4.1. if (is_dir($path = getcwd() . '/vendor/contao/core-bundle/src/Resources/contao')) { $loader = new \Composer\Autoload\ClassLoader(); foreach (array('classes', 'controllers', 'drivers', 'elements', 'forms', 'library', 'models', 'modules', 'pages', 'widgets') as $subDir) { $classMap = ClassMapGenerator::createMap($path . '/' . $subDir); $loader->addClassMap($classMap); } $loader->register(); } // This is the hack to mimic the Contao auto loader. spl_autoload_register(function ($class) { if (substr($class, 0, 7) === 'Contao\\') { return null; } try { spl_autoload_call('Contao\\' . $class); } catch (ParentClassNotFoundException $exception) { return null; } if (EnumeratingClassLoader::isLoaded('Contao\\' . $class) && !EnumeratingClassLoader::isLoaded($class)) {