当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassLoader::findFile方法代码示例

本文整理汇总了PHP中Composer\Autoload\ClassLoader::findFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::findFile方法的具体用法?PHP ClassLoader::findFile怎么用?PHP ClassLoader::findFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Autoload\ClassLoader的用法示例。


在下文中一共展示了ClassLoader::findFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: locateClass

 /**
  * 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;
 }
开发者ID:goaop,项目名称:parser-reflection,代码行数:15,代码来源:ComposerLocator.php

示例2: locate

 /**
  * 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;
 }
开发者ID:daodaoliang,项目名称:nooku-framework,代码行数:15,代码来源:composer.php

示例3: locate

 /**
  * 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;
 }
开发者ID:nooku,项目名称:nooku-framework,代码行数:14,代码来源:composer.php

示例4: loadClass

 /**
  * @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);
 }
开发者ID:donquixote,项目名称:hasty-reflection-common,代码行数:12,代码来源:ClassLoader_Composer.php

示例5: getPathsForClass

 /**
  * 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)] : [];
 }
开发者ID:tsufeki,项目名称:phpcmplr,代码行数:16,代码来源:ComposerPackage.php

示例6: loadClass

 /**
  * @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;
 }
开发者ID:komex,项目名称:influence,代码行数:15,代码来源:Influence.php

示例7: __invoke

 /**
  * @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);
 }
开发者ID:GeeH,项目名称:BetterReflection,代码行数:15,代码来源:ComposerSourceLocator.php

示例8: __invoke

 /**
  * @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);
 }
开发者ID:stof,项目名称:BetterReflection,代码行数:15,代码来源:ComposerSourceLocator.php

示例9: findFile

 /**
  * {@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);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:16,代码来源:ClassLoaderWrapper.php

示例10: loadClass

 /**
  * 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;
 }
开发者ID:unialteri,项目名称:states,代码行数:46,代码来源:LoaderComposer.php

示例11: removeUnloadableClassesFrom

 /**
  * @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;
 }
开发者ID:mamuz,项目名称:squeezer,代码行数:22,代码来源:Filter.php

示例12: findFile

 /**
  * 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;
 }
开发者ID:phavour,项目名称:phavour,代码行数:15,代码来源:ApcClassLoader.php

示例13: findClassFile

 /**
  * 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;
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:18,代码来源:Locator.php

示例14: loadClass

 /**
  * 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);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:16,代码来源:ClassAliasLoader.php

示例15: findFile

 /**
  * 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;
 }
开发者ID:goaop,项目名称:ast-manipulator,代码行数:23,代码来源:ComposerHook.php


注:本文中的Composer\Autoload\ClassLoader::findFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。