Permalink
Browse files

change tabs to spaces

  • Loading branch information...
1 parent ff5f4f4 commit bc8204aa1ae2982542fc79d4d490ac920843e352 @giveit-deploy giveit-deploy committed Nov 7, 2012
Showing with 567 additions and 567 deletions.
  1. +567 −567 AutoLoader.php
View
1,134 AutoLoader.php
@@ -14,731 +14,731 @@
class Entity
{
- public $location;
- public $status;
- public $lastCheckTime;
- public $lastCheckCount;
- public $version;
-
- /**
- * Set the properties of the entity
- *
- * @param array $data
- * @return \opensourceame\AutoLoader\Entity
- */
- static function __set_state(array $data) {
-
- $entity = new Entity;
-
- foreach($data as $key => $val) {
- $entity->key = $val;
- }
-
- return $entity;
- }
+ public $location;
+ public $status;
+ public $lastCheckTime;
+ public $lastCheckCount;
+ public $version;
+
+ /**
+ * Set the properties of the entity
+ *
+ * @param array $data
+ * @return \opensourceame\AutoLoader\Entity
+ */
+ static function __set_state(array $data) {
+
+ $entity = new Entity;
+
+ foreach($data as $key => $val) {
+ $entity->key = $val;
+ }
+
+ return $entity;
+ }
}
class AutoLoader
{
- const version = '3.0.0';
- const FOUND = 1;
- const MISSING = 2;
-
- static $instance = null;
-
- private $extensions = array('php', 'inc');
- private $pathsRead = array();
- private $pathsParsed = array();
- private $initialised = false;
-
- private $debug = false;
- private $cache = true;
- private $cacheRead = false;
- private $cacheDir = null;
- private $cacheMaxAge = 0;
- private $cacheMaxLockTime = 60;
- private $cacheMaxWaitTime = 90;
-
- private $index = array();
- private $include = array();
- private $exclude = array();
- private $ignore = array();
-
- private $missingRefreshInterval = 60;
-
- private $configDefaults = array(
- 'debug' => false,
- 'cache' => true,
- 'cacheDir' => '/tmp',
- 'cacheMaxAge' => 0,
- 'cacheMethod' => 'include',
- 'exclude' => array(),
- 'include' => array(),
- 'ignore' => array(),
- );
-
- public function __construct($config = false)
- {
- $this->registerInstance();
-
- $this->readConfigArray($this->configDefaults);
-
- if (is_array($config)) {
- $this->readConfigArray($config);
- }
-
- if (is_string($config)) {
- $this->readConfigFile($config);
- }
-
- spl_autoload_register('\opensourceame\AutoLoader\AutoLoader::load');
- }
-
- /**
- * Read configuration from an array
- *
- * @param array $config an array of config options
- * @return boolean
- */
- public function readConfigArray($config)
- {
- foreach ($this->configDefaults as $key => $val) {
- if (isset($config[$key]))
- $this->$key = $config[$key];
- }
-
- return true;
- }
-
- /**
- * Read config from a YAML file
- *
- * @param string $configFile the config file to read
- * @return boolean
- */
- public function readConfigFile($configFile)
- {
- if (function_exists('yaml_parse_file')) {
- $config = yaml_parse_file($configFile);
-
- } else {
-
- require_once __DIR__ . '/../../third_party/spyc/spyc.php';
-
- $config = \Spyc::YAMLLoad($configFile);
- }
-
- $this->readConfigArray($config);
-
- return true;
-
- }
-
- /**
- * Add a path to the list of excluded paths
- *
- * @param string $path
- * @return boolean
- */
- public function excludePath($path)
- {
- if (is_array($path)) {
- foreach ($path as $p) {
- $this->excludePath($p);
- }
- }
-
- $this->exclude[] = realpath($path);
-
- return true;
- }
-
- /**
- * Add a path to the list of included paths
- *
- * @param string $path
- * @return boolean
- */
- public function includePath($path)
- {
- if (is_array($path)) {
- foreach ($path as $p) {
- $this->includePath($p);
- }
- }
-
- $this->include[] = realpath($path);
-
- return true;
- }
+ const version = '3.0.0';
+ const FOUND = 1;
+ const MISSING = 2;
+
+ static $instance = null;
+
+ private $extensions = array('php', 'inc');
+ private $pathsRead = array();
+ private $pathsParsed = array();
+ private $initialised = false;
+
+ private $debug = false;
+ private $cache = true;
+ private $cacheRead = false;
+ private $cacheDir = null;
+ private $cacheMaxAge = 0;
+ private $cacheMaxLockTime = 60;
+ private $cacheMaxWaitTime = 90;
+
+ private $index = array();
+ private $include = array();
+ private $exclude = array();
+ private $ignore = array();
+
+ private $missingRefreshInterval = 60;
+
+ private $configDefaults = array(
+ 'debug' => false,
+ 'cache' => true,
+ 'cacheDir' => '/tmp',
+ 'cacheMaxAge' => 0,
+ 'cacheMethod' => 'include',
+ 'exclude' => array(),
+ 'include' => array(),
+ 'ignore' => array(),
+ );
+
+ public function __construct($config = false)
+ {
+ $this->registerInstance();
+
+ $this->readConfigArray($this->configDefaults);
+
+ if (is_array($config)) {
+ $this->readConfigArray($config);
+ }
+
+ if (is_string($config)) {
+ $this->readConfigFile($config);
+ }
+
+ spl_autoload_register('\opensourceame\AutoLoader\AutoLoader::load');
+ }
+
+ /**
+ * Read configuration from an array
+ *
+ * @param array $config an array of config options
+ * @return boolean
+ */
+ public function readConfigArray($config)
+ {
+ foreach ($this->configDefaults as $key => $val) {
+ if (isset($config[$key]))
+ $this->$key = $config[$key];
+ }
+
+ return true;
+ }
+
+ /**
+ * Read config from a YAML file
+ *
+ * @param string $configFile the config file to read
+ * @return boolean
+ */
+ public function readConfigFile($configFile)
+ {
+ if (function_exists('yaml_parse_file')) {
+ $config = yaml_parse_file($configFile);
+
+ } else {
+
+ require_once __DIR__ . '/../../third_party/spyc/spyc.php';
+
+ $config = \Spyc::YAMLLoad($configFile);
+ }
+
+ $this->readConfigArray($config);
+
+ return true;
+
+ }
+
+ /**
+ * Add a path to the list of excluded paths
+ *
+ * @param string $path
+ * @return boolean
+ */
+ public function excludePath($path)
+ {
+ if (is_array($path)) {
+ foreach ($path as $p) {
+ $this->excludePath($p);
+ }
+ }
+
+ $this->exclude[] = realpath($path);
+
+ return true;
+ }
+
+ /**
+ * Add a path to the list of included paths
+ *
+ * @param string $path
+ * @return boolean
+ */
+ public function includePath($path)
+ {
+ if (is_array($path)) {
+ foreach ($path as $p) {
+ $this->includePath($p);
+ }
+ }
+
+ $this->include[] = realpath($path);
+
+ return true;
+ }
- /**
- * Create a lock file for the cache. This prevents multiple instances of the autoloader
- * trying to overwrite the cache.
- *
- * @return boolean
- */
- private function createCacheLockFile()
- {
- $lockFile = $this->getCacheLockFilename();
-
- $this->debug("creating lock file $lockFile");
-
- $lockText = "opensourceame AutoLoader\n\n";
- $lockText .= "Version: " . self::version . "\n";
- $lockText .= "PID: " . getmypid() . "\n";
- $lockText .= "Date: " . date("Y-m-d H:i:s") . "\n";
+ /**
+ * Create a lock file for the cache. This prevents multiple instances of the autoloader
+ * trying to overwrite the cache.
+ *
+ * @return boolean
+ */
+ private function createCacheLockFile()
+ {
+ $lockFile = $this->getCacheLockFilename();
+
+ $this->debug("creating lock file $lockFile");
+
+ $lockText = "opensourceame AutoLoader\n\n";
+ $lockText .= "Version: " . self::version . "\n";
+ $lockText .= "PID: " . getmypid() . "\n";
+ $lockText .= "Date: " . date("Y-m-d H:i:s") . "\n";
- return file_put_contents($lockFile, $lockText);
- }
+ return file_put_contents($lockFile, $lockText);
+ }
- /**
- * Write the cache file
- *
- * @return boolean
- */
- private function writeCache()
- {
- if (! $this->cache) {
- return true;
- }
+ /**
+ * Write the cache file
+ *
+ * @return boolean
+ */
+ private function writeCache()
+ {
+ if (! $this->cache) {
+ return true;
+ }
- $cacheFile = $this->getCacheFileName();
- $lockFile = $this->getCacheLockFileName();
+ $cacheFile = $this->getCacheFileName();
+ $lockFile = $this->getCacheLockFileName();
- $cacheContent = "<?php\n";
- $cacheContent .= '$version = "' . self::version . "\";\n";
- $cacheContent .= '$index = ' . var_export($this->index, true) . ";\n";
+ $cacheContent = "<?php\n";
+ $cacheContent .= '$version = "' . self::version . "\";\n";
+ $cacheContent .= '$index = ' . var_export($this->index, true) . ";\n";
- if (! file_put_contents($cacheFile, $cacheContent)) {
- $this->debug("could not write cache to $cacheFile");
+ if (! file_put_contents($cacheFile, $cacheContent)) {
+ $this->debug("could not write cache to $cacheFile");
- return false;
- }
+ return false;
+ }
- chmod($cacheFile, 0777);
+ chmod($cacheFile, 0777);
- $this->debug("wrote cache to $cacheFile");
+ $this->debug("wrote cache to $cacheFile");
- if (file_exists($lockFile)) {
+ if (file_exists($lockFile)) {
- unlink($lockFile);
+ unlink($lockFile);
- $this->debug("removed lock file");
+ $this->debug("removed lock file");
- }
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Read the cache file
- *
- * @return boolean
- */
- private function readCache()
- {
- if (! $this->cache) {
- return false;
- }
+ /**
+ * Read the cache file
+ *
+ * @return boolean
+ */
+ private function readCache()
+ {
+ if (! $this->cache) {
+ return false;
+ }
- $cacheFile = $this->getCacheFileName();
+ $cacheFile = $this->getCacheFileName();
- if (! is_readable($cacheFile)) {
- return false;
- }
+ if (! is_readable($cacheFile)) {
+ return false;
+ }
- include $this->getCacheFileName();
+ include $this->getCacheFileName();
- if ($version != self::version) {
+ if ($version != self::version) {
- $this->debug("cache version ($version) does not match this version (" . self::version . ")");
+ $this->debug("cache version ($version) does not match this version (" . self::version . ")");
- $this->deleteCache();
+ $this->deleteCache();
- return false;
- }
+ return false;
+ }
- $this->index = $index;
- $this->cacheRead = true;
+ $this->index = $index;
+ $this->cacheRead = true;
- $this->debug("read cache from $cacheFile");
- $this->debug(count($this->index) . " classes loaded");
+ $this->debug("read cache from $cacheFile");
+ $this->debug(count($this->index) . " classes loaded");
- return true;
+ return true;
- }
+ }
- /**
- * Log a debugging message
- *
- * @param unknown $message
- * @return boolean
- */
- protected function debug($message)
- {
- if (! $this->debug) {
- return false;
- }
+ /**
+ * Log a debugging message
+ *
+ * @param unknown $message
+ * @return boolean
+ */
+ protected function debug($message)
+ {
+ if (! $this->debug) {
+ return false;
+ }
- openlog('autoloader', false, LOG_USER);
+ openlog('autoloader', false, LOG_USER);
- return syslog(LOG_INFO, $message);
- }
+ return syslog(LOG_INFO, $message);
+ }
- private function searchForMissingClass($class) {
+ private function searchForMissingClass($class) {
- if (! isset($this->index[$class])) {
+ if (! isset($this->index[$class])) {
- $this->addMissingClass($class);
- }
+ $this->addMissingClass($class);
+ }
- $files = array();
+ $files = array();
- $this->debug("searching for missing class $class");
+ $this->debug("searching for missing class $class");
- foreach ($this->include as $path) {
+ foreach ($this->include as $path) {
- $files = $this->globRecursive("$path/*.php");
+ $files = $this->globRecursive("$path/*.php");
- foreach ($files as $file) {
+ foreach ($files as $file) {
- if (basename($file, ".php") === $class ) {
+ if (basename($file, ".php") === $class ) {
- $this->parseFile($file);
+ $this->parseFile($file);
- if ($this->index[$class]->status == self::FOUND) {
+ if ($this->index[$class]->status == self::FOUND) {
- $this->writeCache();
+ $this->writeCache();
- require_once $file;
+ require_once $file;
- return true;
- }
- }
- }
- }
+ return true;
+ }
+ }
+ }
+ }
- // create a missing class entry
+ // create a missing class entry
- $this->writeCache();
+ $this->writeCache();
- return false;
- }
+ return false;
+ }
- /**
- * Load a class
- *
- * @param string $class the name of the class
- * @return boolean
- */
- public function loadClass($className)
- {
- $class = $this->formatClassName($className);
+ /**
+ * Load a class
+ *
+ * @param string $class the name of the class
+ * @return boolean
+ */
+ public function loadClass($className)
+ {
+ $class = $this->formatClassName($className);
- $this->debug("loading $class");
+ $this->debug("loading $class");
- if (! isset($this->index[$class])) {
+ if (! isset($this->index[$class])) {
- return $this->searchForMissingClass($className);
- }
+ return $this->searchForMissingClass($className);
+ }
- $entity = &$this->index[$class];
+ $entity = &$this->index[$class];
- // if we have the entity and it is found, include the file
+ // if we have the entity and it is found, include the file
- if ($entity->status == self::FOUND) {
+ if ($entity->status == self::FOUND) {
- require_once $entity->location;
+ require_once $entity->location;
- return true;
- }
+ return true;
+ }
- if ($entity->status == self::MISSING) {
+ if ($entity->status == self::MISSING) {
- // if we've passed the time to try a refresh then search
+ // if we've passed the time to try a refresh then search
- if ($entity->lastCheckTime < (time() - $this->missingRefreshInterval)) {
+ if ($entity->lastCheckTime < (time() - $this->missingRefreshInterval)) {
- return $this->searchForMissingClass($className);
- }
+ return $this->searchForMissingClass($className);
+ }
- // otherwise fail
+ // otherwise fail
- $this->debug("missing class $class, failing");
+ $this->debug("missing class $class, failing");
- return false;
- }
+ return false;
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Load a class. This function gets the singleton and calls its loadClass() method
- *
- * @param string $class
- */
- public function load($class)
- {
+ /**
+ * Load a class. This function gets the singleton and calls its loadClass() method
+ *
+ * @param string $class
+ */
+ public function load($class)
+ {
- $autoloader = autoloader::getInstance();
+ $autoloader = autoloader::getInstance();
- $autoloader->init();
+ $autoloader->init();
- return $autoloader->loadClass($class);
+ return $autoloader->loadClass($class);
- }
+ }
- /**
- * Get the singleton
- *
- * @return unknown
- */
- static public function getInstance()
- {
- return $GLOBALS['__opensourceame_autoloader'];
- }
+ /**
+ * Get the singleton
+ *
+ * @return unknown
+ */
+ static public function getInstance()
+ {
+ return $GLOBALS['__opensourceame_autoloader'];
+ }
- /**
- * Register the singleton
- *
- * @return boolean
- */
- protected function registerInstance()
- {
- $GLOBALS['__opensourceame_autoloader'] =& $this;
+ /**
+ * Register the singleton
+ *
+ * @return boolean
+ */
+ protected function registerInstance()
+ {
+ $GLOBALS['__opensourceame_autoloader'] =& $this;
- return true;
- }
+ return true;
+ }
- /**
- * Delete the cache file
- *
- * @return boolean
- */
- private function deleteCache()
- {
- unlink($this->getCacheFileName());
+ /**
+ * Delete the cache file
+ *
+ * @return boolean
+ */
+ private function deleteCache()
+ {
+ unlink($this->getCacheFileName());
- $this->debug("deleted cache file");
+ $this->debug("deleted cache file");
- return true;
- }
+ return true;
+ }
- /**
- * Initialise the autoloader
- *
- * @param boolean $forceInit whether to force initialisation
- * @return boolean
- */
- public function init($forceInit = false)
- {
- if ($this->initialised and ! $forceInit) {
- return true;
- }
+ /**
+ * Initialise the autoloader
+ *
+ * @param boolean $forceInit whether to force initialisation
+ * @return boolean
+ */
+ public function init($forceInit = false)
+ {
+ if ($this->initialised and ! $forceInit) {
+ return true;
+ }
- $this->debug('initialising');
+ $this->debug('initialising');
- // get the real paths for exclusion
- foreach ($this->exclude as $key => $path) {
- $this->exclude[$key] = realpath($path);
- }
+ // get the real paths for exclusion
+ foreach ($this->exclude as $key => $path) {
+ $this->exclude[$key] = realpath($path);
+ }
- // get the real paths for inclusion
- foreach ($this->include as $key => $path) {
- $this->include[$key] = realpath($path);
- }
+ // get the real paths for inclusion
+ foreach ($this->include as $key => $path) {
+ $this->include[$key] = realpath($path);
+ }
- // get the classes to ignore in specific locations
- foreach ($this->ignore as $key => $val) {
+ // get the classes to ignore in specific locations
+ foreach ($this->ignore as $key => $val) {
- if (is_array($val)) {
+ if (is_array($val)) {
- foreach ($val as $k => $v) {
- $ignore[$this->formatClassName($key)][$k] = realpath($v);
+ foreach ($val as $k => $v) {
+ $ignore[$this->formatClassName($key)][$k] = realpath($v);
- $this->ignore = $ignore;
- }
- } else {
- $this->ignore[$this->formatClassName($key)] = realpath($val);
- }
- }
+ $this->ignore = $ignore;
+ }
+ } else {
+ $this->ignore[$this->formatClassName($key)] = realpath($val);
+ }
+ }
- // kill the cache file if initialisation is forced
- if ($forceInit) {
+ // kill the cache file if initialisation is forced
+ if ($forceInit) {
- $this->debug("killing cache file due to forced init");
+ $this->debug("killing cache file due to forced init");
- $this->deleteCache();
- }
+ $this->deleteCache();
+ }
- // now try to read the cache file if possible
- if ($this->readCache()) {
+ // now try to read the cache file if possible
+ if ($this->readCache()) {
- $this->initialised = true;
+ $this->initialised = true;
- return true;
- }
+ return true;
+ }
- $lockFile = $this->getCacheLockFileName();
+ $lockFile = $this->getCacheLockFileName();
- if ($this->cache) {
- if (! file_exists($lockFile)) {
+ if ($this->cache) {
+ if (! file_exists($lockFile)) {
- $this->createCacheLockFile();
+ $this->createCacheLockFile();
- } else {
- $waitCount = 0;
+ } else {
+ $waitCount = 0;
- while (! file_exists($this->getCacheFileName())) {
+ while (! file_exists($this->getCacheFileName())) {
- $lockTime = filemtime($lockFile);
- $lockAge = time() - $lockTime;
+ $lockTime = filemtime($lockFile);
+ $lockAge = time() - $lockTime;
- if ($lockAge > $this->cacheMaxLockTime) {
+ if ($lockAge > $this->cacheMaxLockTime) {
- $this->debug("lock file is $lockAge seconds old, deleting");
+ $this->debug("lock file is $lockAge seconds old, deleting");
- unlink($lockFile);
+ unlink($lockFile);
- return $this->init();
- }
+ return $this->init();
+ }
- sleep(1);
+ sleep(1);
- $this->debug("waiting for cache file to complete");
+ $this->debug("waiting for cache file to complete");
- $waitCount ++;
+ $waitCount ++;
- if ($waitCount > $this->cacheMaxWaitTime) {
+ if ($waitCount > $this->cacheMaxWaitTime) {
- $this->debug("waited $waitCount seconds but cache was still locked");
- $this->debug("aborting");
+ $this->debug("waited $waitCount seconds but cache was still locked");
+ $this->debug("aborting");
- return false;
- }
- }
+ return false;
+ }
+ }
- if ($this->readCache()) {
+ if ($this->readCache()) {
- $this->initialised = true;
+ $this->initialised = true;
- return true;
- }
- }
- }
+ return true;
+ }
+ }
+ }
- foreach ($this->include as $path) {
- $this->readDirectory($path);
- }
+ foreach ($this->include as $path) {
+ $this->readDirectory($path);
+ }
- $this->writeCache();
+ $this->writeCache();
- $this->initialised = true;
+ $this->initialised = true;
- return true;
- }
+ return true;
+ }
- /**
- * Generate a cache file name based on the config for this autoloader
- *
- * @return string
- */
- public function getCacheFileName()
- {
- $tmp = array(
- 'in' => $this->include,
- 'ex' => $this->exclude,
- 'ign' => $this->ignore,
- );
+ /**
+ * Generate a cache file name based on the config for this autoloader
+ *
+ * @return string
+ */
+ public function getCacheFileName()
+ {
+ $tmp = array(
+ 'in' => $this->include,
+ 'ex' => $this->exclude,
+ 'ign' => $this->ignore,
+ );
- if ($this->cacheMethod == 'include') {
- $ext = 'php';
- } else {
- $ext = 'cache';
- }
+ if ($this->cacheMethod == 'include') {
+ $ext = 'php';
+ } else {
+ $ext = 'cache';
+ }
- return $this->cacheDir . "/autoloader." . md5(serialize($tmp)) . ".$ext";
- }
+ return $this->cacheDir . "/autoloader." . md5(serialize($tmp)) . ".$ext";
+ }
- /**
- * Get the lock file name for a cache file
- *
- * @return string
- */
- public function getCacheLockFileName()
- {
- return $this->getCacheFileName() . '.lock';
- }
+ /**
+ * Get the lock file name for a cache file
+ *
+ * @return string
+ */
+ public function getCacheLockFileName()
+ {
+ return $this->getCacheFileName() . '.lock';
+ }
- /**
- * Read a directory
- *
- * @param string $path
- * @return boolean
- */
- public function readDirectory($path)
- {
- $path = realpath($path);
+ /**
+ * Read a directory
+ *
+ * @param string $path
+ * @return boolean
+ */
+ public function readDirectory($path)
+ {
+ $path = realpath($path);
- $this->debug("reading $path");
+ $this->debug("reading $path");
- $this->pathsRead[] = $path;
+ $this->pathsRead[] = $path;
- $files = $this->globRecursive("$path/*");
+ $files = $this->globRecursive("$path/*");
- foreach ($files as $file) {
+ foreach ($files as $file) {
- $ext = substr($file, strrpos($file, '.') + 1);
+ $ext = substr($file, strrpos($file, '.') + 1);
- if (in_array($ext, $this->extensions)) {
- $this->parseFile($file);
- }
- }
+ if (in_array($ext, $this->extensions)) {
+ $this->parseFile($file);
+ }
+ }
- ksort($this->index);
+ ksort($this->index);
- $this->pathsParsed = true;
+ $this->pathsParsed = true;
- return true;
- }
+ return true;
+ }
- /**
- * Parse a file and index the result
- *
- * @param string $filename
- */
- private function parseFile($filename)
- {
+ /**
+ * Parse a file and index the result
+ *
+ * @param string $filename
+ */
+ private function parseFile($filename)
+ {
// $this->debug("parsing $filename");
- $content = file($filename);
- $namespace = null;
+ $content = file($filename);
+ $namespace = null;
- foreach ($content as $line) {
+ foreach ($content as $line) {
- if (preg_match("/^\s*(namespace)\s+(.*).*;$/", $line, $matches)) {
- $namespace = $matches[2];
- }
+ if (preg_match("/^\s*(namespace)\s+(.*).*;$/", $line, $matches)) {
+ $namespace = $matches[2];
+ }
- if (preg_match("/^\s*(abstract|final)*\s*(class|interface|trait)\s+(\w*).*$/", $line, $matches)) {
+ if (preg_match("/^\s*(abstract|final)*\s*(class|interface|trait)\s+(\w*).*$/", $line, $matches)) {
- $className = $matches[3];
+ $className = $matches[3];
- $this->addFoundClass($filename, $namespace, $className);
- }
- }
+ $this->addFoundClass($filename, $namespace, $className);
+ }
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Format a class name so that MyNameSpace\MyClass becomes \\mynamespace\\myclass
- *
- * @param string $class
- * @return string
- */
- private function formatClassName($class)
- {
- if (substr($class, 0, 1) != '\\') {
- $class = '\\' . $class;
- }
+ /**
+ * Format a class name so that MyNameSpace\MyClass becomes \\mynamespace\\myclass
+ *
+ * @param string $class
+ * @return string
+ */
+ private function formatClassName($class)
+ {
+ if (substr($class, 0, 1) != '\\') {
+ $class = '\\' . $class;
+ }
- $class = strtolower($class);
+ $class = strtolower($class);
- return $class;
- }
+ return $class;
+ }
- private function addMissingClass($className)
- {
- $class = $this->formatClassName($className);
+ private function addMissingClass($className)
+ {
+ $class = $this->formatClassName($className);
- $entity = new \opensourceame\AutoLoader\Entity;
- $entity->name = $className;
- $entity->location = null;
- $entity->namespace = null;
- $entity->status = self::MISSING;
- $entity->lastCheckTime = time();
- $entity->lastCheckCount = 1;
+ $entity = new \opensourceame\AutoLoader\Entity;
+ $entity->name = $className;
+ $entity->location = null;
+ $entity->namespace = null;
+ $entity->status = self::MISSING;
+ $entity->lastCheckTime = time();
+ $entity->lastCheckCount = 1;
- $this->index[$class] = $entity;
+ $this->index[$class] = $entity;
- $this->missing[$class] = &$this->index[$class];
- }
+ $this->missing[$class] = &$this->index[$class];
+ }
- private function addFoundClass($filename, $namespace, $className)
- {
- $class = $this->formatClassName("$namespace\\$className");
+ private function addFoundClass($filename, $namespace, $className)
+ {
+ $class = $this->formatClassName("$namespace\\$className");
- if (isset($this->index[$class])) {
+ if (isset($this->index[$class])) {
- $this->debug("duplicate class name $class in $filename");
+ $this->debug("duplicate class name $class in $filename");
- return false;
- }
+ return false;
+ }
- if (isset($this->ignore[$class]) and (in_array($filename, $this->ignore[$class]))) {
+ if (isset($this->ignore[$class]) and (in_array($filename, $this->ignore[$class]))) {
- $this->debug("ingoring $class in $filename");
+ $this->debug("ingoring $class in $filename");
- return false;
- }
+ return false;
+ }
- $entity = new \opensourceame\AutoLoader\Entity;
- $entity->name = $className;
- $entity->location = $filename;
- $entity->namespace = $namespace;
- $entity->status = self::FOUND;
- $entity->lastCheckTime = time();
- $entity->lastCheckCount = 1;
+ $entity = new \opensourceame\AutoLoader\Entity;
+ $entity->name = $className;
+ $entity->location = $filename;
+ $entity->namespace = $namespace;
+ $entity->status = self::FOUND;
+ $entity->lastCheckTime = time();
+ $entity->lastCheckCount = 1;
/*
- if ($class::version) {
- $entity->version = $class::version;
- }
+ if ($class::version) {
+ $entity->version = $class::version;
+ }
*/
- $this->index[$class] = $entity;
-
- return true;
- }
-
- /**
- * Recursively glob a directory, fetching only directories
- *
- * @param string $pattern
- * @param number $flags
- * @return array
- */
- private function globRecursive($pattern, $flags = 0)
- {
-
- $files = glob($pattern, $flags);
-
- foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
-
- if (in_array($dir, $this->exclude)) {
- $this->debug("excluding directory $dir");
-
- continue;
- }
-
- $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
- }
-
- return $files;
- }
-
- /**
- * return the index
- *
- * @return array
- */
- public function index()
- {
- return $this->index;
- }
+ $this->index[$class] = $entity;
+
+ return true;
+ }
+
+ /**
+ * Recursively glob a directory, fetching only directories
+ *
+ * @param string $pattern
+ * @param number $flags
+ * @return array
+ */
+ private function globRecursive($pattern, $flags = 0)
+ {
+
+ $files = glob($pattern, $flags);
+
+ foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
+
+ if (in_array($dir, $this->exclude)) {
+ $this->debug("excluding directory $dir");
+
+ continue;
+ }
+
+ $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
+ }
+
+ return $files;
+ }
+
+ /**
+ * return the index
+ *
+ * @return array
+ */
+ public function index()
+ {
+ return $this->index;
+ }
}

0 comments on commit bc8204a

Please sign in to comment.