Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Classloader] Added phpdoc with example usage + refactored unit tests…

… fixtures
  • Loading branch information...
commit 476a4ae2161120c8cc8b0c5891235eb46cb27463 1 parent ce52f93
@dustinwhittle dustinwhittle authored
Showing with 50 additions and 1 deletion.
  1. +50 −1 ApcUniversalClassLoader.php
View
51 ApcUniversalClassLoader.php
@@ -12,8 +12,50 @@
namespace Symfony\Component\ClassLoader;
/**
- * Class loader utilizing APC to remember where files are.
+ * ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3.
*
+ * It is able to load classes that use either:
+ *
+ * * The technical interoperability standards for PHP 5.3 namespaces and
+ * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
+ *
+ * * The PEAR naming convention for classes (http://pear.php.net/).
+ *
+ * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
+ * looked for in a list of locations to ease the vendoring of a sub-set of
+ * classes for large projects.
+ *
+ * Example usage:
+ *
+ * require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+ * require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
+ *
+ * use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
+ *
+ * $loader = new ApcUniversalClassLoader('apc.prefix.');
+ *
+ * // register classes with namespaces
+ * $loader->registerNamespaces(array(
+ * 'Symfony\Component' => __DIR__.'/component',
+ * 'Symfony' => __DIR__.'/framework',
+ * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
+ * ));
+ *
+ * // register a library using the PEAR naming convention
+ * $loader->registerPrefixes(array(
+ * 'Swift_' => __DIR__.'/Swift',
+ * ));
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
* @author Kris Wallsmith <kris.wallsmith@symfony.com>
*
* @api
@@ -34,6 +76,13 @@ public function __construct($prefix)
$this->prefix = $prefix;
}
+ /**
+ * Finds a file by class name while caching lookups to APC.
+ *
+ * @param string $class A class name to resolve to file
+ *
+ * @api
+ */
public function findFile($class)
{
if (false === $file = apc_fetch($this->prefix.$class)) {

0 comments on commit 476a4ae

Please sign in to comment.
Something went wrong with that request. Please try again.