[2.1][Component][ClassLoader] cs

This commit is contained in:
Włodzimierz Gajda 2012-04-23 07:25:09 +02:00
parent 6c714095fa
commit bc8855e46a
6 changed files with 29 additions and 9 deletions

View File

@ -47,8 +47,8 @@ class ApcClassLoader
/** /**
* Constructor. * Constructor.
* *
* @param string $prefix A prefix to create a namespace in APC * @param string $prefix A prefix to create a namespace in APC
* @param object $classFinder * @param object $classFinder An object that implements findFile() method.
* *
* @api * @api
*/ */
@ -88,6 +88,7 @@ class ApcClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
*
* @return Boolean|null True, if loaded * @return Boolean|null True, if loaded
*/ */
public function loadClass($class) public function loadClass($class)

View File

@ -25,7 +25,7 @@ namespace Symfony\Component\ClassLoader;
* // activate the autoloader * // activate the autoloader
* $loader->register(); * $loader->register();
* *
* // to enable searching the include path (eg. for PEAR packages) * // to enable searching the include path (e.g. for PEAR packages)
* $loader->setUseIncludePath(true); * $loader->setUseIncludePath(true);
* *
* In this example, if you try to use a class in the Symfony\Component * In this example, if you try to use a class in the Symfony\Component
@ -43,16 +43,31 @@ class ClassLoader
private $fallbackDirs = array(); private $fallbackDirs = array();
private $useIncludePath = false; private $useIncludePath = false;
/**
* Returns prefixes.
*
* @return array
*/
public function getPrefixes() public function getPrefixes()
{ {
return $this->prefixes; return $this->prefixes;
} }
/**
* Returns fallback directories.
*
* @return array
*/
public function getFallbackDirs() public function getFallbackDirs()
{ {
return $this->fallbackDirs; return $this->fallbackDirs;
} }
/**
* Adds prefixes.
*
* @param array $prefixes Prefixes to add
*/
public function addPrefixes(array $prefixes) public function addPrefixes(array $prefixes)
{ {
foreach ($prefixes as $prefix => $path) { foreach ($prefixes as $prefix => $path) {
@ -63,8 +78,8 @@ class ClassLoader
/** /**
* Registers a set of classes * Registers a set of classes
* *
* @param string $prefix The classes prefix * @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes * @param array|string $paths The location(s) of the classes
*/ */
public function addPrefix($prefix, $paths) public function addPrefix($prefix, $paths)
{ {
@ -128,6 +143,7 @@ class ClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
*
* @return Boolean|null True, if loaded * @return Boolean|null True, if loaded
*/ */
public function loadClass($class) public function loadClass($class)

View File

@ -22,7 +22,7 @@ class ClassMapGenerator
* Generate a class map file * Generate a class map file
* *
* @param array|string $dirs Directories or a single path to search in * @param array|string $dirs Directories or a single path to search in
* @param string $file The name of the class map file * @param string $file The name of the class map file
*/ */
static public function dump($dirs, $file) static public function dump($dirs, $file)
{ {

View File

@ -73,6 +73,7 @@ class DebugClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
*
* @return Boolean|null True, if loaded * @return Boolean|null True, if loaded
*/ */
public function loadClass($class) public function loadClass($class)

View File

@ -42,7 +42,7 @@ namespace Symfony\Component\ClassLoader;
* )); * ));
* *
* *
* // to enable searching the include path (eg. for PEAR packages) * // to enable searching the include path (e.g. for PEAR packages)
* $loader->useIncludePath(true); * $loader->useIncludePath(true);
* *
* // activate the autoloader * // activate the autoloader

View File

@ -48,8 +48,8 @@ class XcacheClassLoader
/** /**
* Constructor. * Constructor.
* *
* @param string $prefix A prefix to create a namespace in Xcache * @param string $prefix A prefix to create a namespace in Xcache
* @param object $classFinder * @param object $classFinder An object that implements findFile() method.
* *
* @api * @api
*/ */
@ -89,12 +89,14 @@ class XcacheClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
*
* @return Boolean|null True, if loaded * @return Boolean|null True, if loaded
*/ */
public function loadClass($class) public function loadClass($class)
{ {
if ($file = $this->findFile($class)) { if ($file = $this->findFile($class)) {
require $file; require $file;
return true; return true;
} }
} }