/**
  * Returns a path to the file for given class name
  *
  * @param string $className Name of the class
  *
  * @return string|false Path to the file with given class or false if not found
  */
 public function locateClass($className)
 {
     $filePath = $this->loader->findFile($className);
     if (!empty($filePath)) {
         $filePath = PathResolver::realpath($filePath);
     }
     return $filePath;
 }
示例#2
0
 /**
  * Get a fully qualified path based on a class name
  *
  * @param  string $class     The class name
  * @param  string $basepath  The base path
  * @return string|false Returns canonicalized absolute pathname or FALSE of the class could not be found.
  */
 public function locate($class, $basepath = null)
 {
     $path = false;
     if ($this->_loader) {
         $path = $this->_loader->findFile($class);
     }
     return $path;
 }
示例#3
0
 /**
  * Get a fully qualified path based on a class name
  *
  * @param  string $class     The class name
  * @return string|false Returns canonicalized absolute pathname or FALSE of the class could not be found.
  */
 public function locate($class)
 {
     $path = false;
     if (self::$__loader) {
         $path = self::$__loader->findFile($class);
     }
     return $path;
 }
 /**
  * @param string $class
  * @param \Donquixote\HastyReflectionCommon\Canvas\ClassLoaderCanvas\ClassLoaderCanvasInterface $canvas
  */
 function loadClass($class, ClassLoaderCanvasInterface $canvas)
 {
     $file = $this->composerClassLoader->findFile($class);
     if (FALSE === $file) {
         return;
     }
     $canvas->includeOnce($file);
 }
示例#5
0
 /**
  * Find file(s) defining given class.
  *
  * @param string $class Fully qualified name.
  *
  * @return string[] Paths.
  */
 public function getPathsForClass($class)
 {
     if ($class !== '' && $class[0] === '\\') {
         $class = substr($class, 1);
     }
     $file = $this->classLoader->findFile($class);
     // TODO: ensure it's an absolute path.
     return is_string($file) ? [str_replace('//', '/', $file)] : [];
 }
示例#6
0
 /**
  * @param string $class
  *
  * @return bool
  */
 public function loadClass($class)
 {
     if (strpos(ltrim($class, '\\'), __NAMESPACE__) === 0) {
         return $this->composer->loadClass($class);
     } elseif ($file = $this->composer->findFile($class)) {
         \Composer\Autoload\includeFile('php://filter/read=influence.reader/resource=' . $file);
         return true;
     }
     return false;
 }
 /**
  * @param Identifier $identifier
  * @return LocatedSource
  */
 public function __invoke(Identifier $identifier)
 {
     if ($identifier->getType()->getName() !== IdentifierType::IDENTIFIER_CLASS) {
         throw new \LogicException(__CLASS__ . ' can only be used to locate classes');
     }
     $filename = $this->classLoader->findFile($identifier->getName());
     if (!$filename) {
         throw new \UnexpectedValueException(sprintf('Could not locate file to load "%s"', $identifier->getName()));
     }
     return new LocatedSource(file_get_contents($filename), $filename);
 }
 /**
  * @param Identifier $identifier
  * @return LocatedSource|null
  */
 public function __invoke(Identifier $identifier)
 {
     if ($identifier->getType()->getName() !== IdentifierType::IDENTIFIER_CLASS) {
         return null;
     }
     $filename = $this->classLoader->findFile($identifier->getName());
     if (!$filename) {
         return null;
     }
     return new LocatedSource(file_get_contents($filename), $filename);
 }
 /**
  * {@inheritdoc}
  * @codeCoverageIgnore
  */
 public function findFile($className)
 {
     /**
      * Composer remembers that files don't exist even after they are generated. This clears the entry for
      * $className so we can check the filesystem again for class existence.
      */
     if ($className[0] === '\\') {
         $className = substr($className, 1);
     }
     $this->autoloader->addClassMap([$className => null]);
     return $this->autoloader->findFile($className);
 }
示例#10
0
 /**
  * Method called to load a class by __autoload of PHP Engine.
  * The class name can be the canonical stated class name or the canonical proxy class name of the stated class.
  *
  * @api
  *
  * @param string $className canonical class name
  *
  * @return bool
  *
  * @throws Exception\UnavailableFactory if the required factory is not available
  * @throws Exception\IllegalFactory     if the factory does not implement the good interface
  * @throws \Exception
  */
 public function loadClass(string $className) : bool
 {
     //Do nothing if this loader has already check the required class name or if the class provide from this library
     if (0 === \strpos($className, 'Teknoo\\States')) {
         return false;
     }
     //Found the canonical factory name from the stated class name
     $factoryClassName = $className . '\\' . LoaderInterface::FACTORY_CLASS_NAME;
     if (isset($this->loadingFactoriesClassNameArray[$factoryClassName])) {
         return $this->loadingFactoriesClassNameArray[$factoryClassName];
     }
     //Try to load the factory
     $statedClassName = $className;
     $factoryClassFound = $this->loadFactory($factoryClassName);
     if (false === $factoryClassFound) {
         //Factory not found, the stated class name may be loaded from it's proxy class name :
         //Retry to generate the canonical factory class name from the proxy class name
         $canonicalClassNameParts = \explode('\\', $className);
         \array_pop($canonicalClassNameParts);
         $statedClassName = \implode('\\', $canonicalClassNameParts);
         $factoryClassName = $statedClassName . '\\' . LoaderInterface::FACTORY_CLASS_NAME;
         $factoryClassFound = $this->loadFactory($factoryClassName);
     }
     if (true === $factoryClassFound) {
         //The factory has been found, build a new instance of it to initialize the required stated class
         $this->buildFactory($factoryClassName, $statedClassName, \dirname($this->composerInstance->findFile($factoryClassName)));
         $this->loadingFactoriesClassNameArray[$factoryClassName] = true;
         return true;
     }
     $this->loadingFactoriesClassNameArray[$factoryClassName] = false;
     return false;
 }
示例#11
0
文件: Filter.php 项目: mamuz/squeezer
 /**
  * @param array $classMap
  * @return array
  */
 private function removeUnloadableClassesFrom(array $classMap)
 {
     foreach ($classMap as $class => $dependencies) {
         if (!$this->classloader->findFile($class)) {
             unset($classMap[$class]);
             $classMap = $this->removeUnloadableClassesFrom($classMap);
             break;
         }
         foreach ($dependencies as $dependency) {
             if (!isset($classMap[$dependency]) || !$this->classloader->findFile($dependency)) {
                 unset($classMap[$class]);
                 $classMap = $this->removeUnloadableClassesFrom($classMap);
                 break 2;
             }
         }
     }
     return $classMap;
 }
示例#12
0
 /**
  * Finds the file from the cache or the autoloader
  *
  * @param string $class
  * @return false|string
  */
 public function findFile($class)
 {
     $file = apc_fetch($this->key . $class);
     if (!$file) {
         $file = $this->loader->findFile($class);
         apc_store($this->key . $class, $file);
     }
     return $file;
 }
示例#13
0
 /**
  * Find class file for class
  *
  * @param string $class   Class name
  * @param string $baseDir
  *
  * @return string The filename or false if file not found
  */
 public function findClassFile($class, $baseDir = null)
 {
     $baseDir = is_null($baseDir) ? getcwd() : $baseDir;
     $file = $this->mainLoader->findFile($class);
     if (is_file($file)) {
         $spl = PathUtil::createSplFileInfo($baseDir, $file);
         return $spl;
     }
     return false;
 }
示例#14
0
 /**
  * Load class with the option to respect case insensitivity
  *
  * @param string $className
  * @return bool|null
  */
 public function loadClass($className)
 {
     if (!$this->caseSensitiveClassLoading) {
         $lowerCasedClassName = strtolower($className);
         if ($this->composerClassLoader->findFile($lowerCasedClassName)) {
             return $this->composerClassLoader->loadClass($lowerCasedClassName);
         }
     }
     return $this->composerClassLoader->loadClass($className);
 }
示例#15
0
 /**
  * Finds the path to the file where the class is defined.
  *
  * @param string $class The name of the class
  *
  * @return string|false The path if found, false otherwise
  *
  * @see \Composer\Autoload\ClassLoader::findFile
  */
 public function findFile($class)
 {
     $file = $this->original->findFile($class);
     if ($file) {
         $cacheState = isset($this->cacheState[$file]) ? $this->cacheState[$file] : null;
         if ($cacheState && self::$isProductionMode) {
             $file = $cacheState['cacheUri'] ?: $file;
         } elseif (Engine::shouldProcess($file)) {
             // can be optimized here with $cacheState even for debug mode, but no needed right now
             $file = AstSourceFilter::getTransformedSourcePath($file);
         }
     }
     return $file;
 }
 /**
  * @param $name
  *
  * @return PhpFileInfo|null
  */
 protected function findDefinitionFileByComposer($name)
 {
     if (null === $this->composerLoader) {
         $this->initComposerLoader();
     }
     if (false === $this->composerLoader) {
         return;
     }
     $filePath = $this->composerLoader->findFile($name);
     if (empty($filePath)) {
         return;
     }
     $file = new PhpFileInfo($filePath, null, null);
     return $this->container['parser.usage']->parseFile($file);
 }
示例#17
0
 /**
  * @param string $class Load and patch class
  *
  * @return bool|void
  */
 public function autoload($class)
 {
     if (isset($this->patchers[$class])) {
         $file = $this->classLoader->findFile($class);
         if (!$file) {
             return;
         }
         $contents = preg_replace('/^(<\\?php)|(<\\?)$/', '', file_get_contents($file));
         // Remove opening PHP tags
         eval($this->patchers[$class]($contents));
         // Eval, yayyy!
         return true;
     }
     return;
 }
示例#18
0
 /**
  * {@inheritDoc}
  */
 public function findFile($class)
 {
     static $isAllowedFilter = null, $isProduction = false;
     if (!$isAllowedFilter) {
         $isAllowedFilter = $this->fileEnumerator->getFilter();
         $isProduction = !$this->options['debug'];
     }
     $file = $this->original->findFile($class);
     if ($file) {
         $cacheState = isset($this->cacheState[$file]) ? $this->cacheState[$file] : null;
         if ($cacheState && $isProduction) {
             $file = $cacheState['cacheUri'] ?: $file;
         } elseif ($isAllowedFilter(new \SplFileInfo($file))) {
             // can be optimized here with $cacheState even for debug mode, but no needed right now
             $file = FilterInjectorTransformer::rewrite($file);
         }
     }
     return $file;
 }
示例#19
0
 /**
  * @param \Composer\Autoload\ClassLoader $loader
  *
  * @return \Eloquent\Pathogen\RelativePathInterface|\Eloquent\Pathogen\AbsolutePathInterface
  */
 public function useLoader(ClassLoader $loader)
 {
     $this->classLoader = $loader;
     $loaderPath = dirname($loader->findFile('Composer\\Autoload\\ClassLoader'));
     // Remove last vendor/* off loaderPath to get our root path
     list($rootPath) = explode('vendor', $loaderPath, -1);
     return $this->setPath('root', $rootPath);
 }
 /**
  * Returns a path to the file for given class name
  *
  * @param string $className Name of the class
  *
  * @return string|false Path to the file with given class or false if not found
  */
 public function locateClass($className)
 {
     return $this->loader->findFile($className);
 }
示例#21
0
 public function useLoader(ClassLoader $loader)
 {
     $this->classLoader = $loader;
     $app = dirname($loader->findFile('Bolt\\Application'));
     $this->root = realpath($app . '/../../../');
 }
示例#22
0
 public function getView($path)
 {
     $class = $this->loader->findFile($this->normalize($path, defined('VIEW_DIR') ? VIEW_DIR : 'App\\View'));
     return file_exists($class) ? realpath($class) : false;
 }
示例#23
0
文件: Core.php 项目: boolive/core
 /**
  * Путь на файл класса по стандарту PSR-0
  * @param string $class_name Имя класса с namespace
  * @return string Путь к файлу от корня сервера
  */
 public static function getClassFile($class_name)
 {
     return self::$loader->findFile($class_name);
 }
示例#24
0
 /**
  * {@inheritDoc}
  */
 public function findFile($class)
 {
     return $this->original->findFile($class);
 }