本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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)] : [];
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}