當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。