diff --git a/fproject/Zend/Loader/Autoloader.php b/fproject/amf/loader/Autoloader.php similarity index 81% rename from fproject/Zend/Loader/Autoloader.php rename to fproject/amf/loader/Autoloader.php index fb70e24..47188a5 100644 --- a/fproject/Zend/Loader/Autoloader.php +++ b/fproject/amf/loader/Autoloader.php @@ -1,41 +1,33 @@ getClassAutoloaders($class) as $autoloader) { - if ($autoloader instanceof Zend_Loader_Autoloader_Interface) { + if ($autoloader instanceof AutoloaderInterface) { if ($autoloader->autoload($class)) { return true; } @@ -139,12 +131,12 @@ public static function autoload($class) * * @param string|array $callback PHP callback * @return $this - * @throws \fproject\amf\AmfException + * @throws AmfException */ public function setDefaultAutoloader($callback) { if (!is_callable($callback)) { - throw new \fproject\amf\AmfException('Invalid callback specified for default autoloader'); + throw new AmfException('Invalid callback specified for default autoloader'); } $this->_defaultAutoloader = $callback; @@ -164,8 +156,8 @@ public function getDefaultAutoloader() /** * Set several autoloader callbacks at once * - * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders - * @return Zend_Loader_Autoloader + * @param array $autoloaders Array of PHP callbacks (or AutoloaderInterface implementations) to act as autoloaders + * @return Autoloader */ public function setAutoloaders(array $autoloaders) { @@ -202,15 +194,15 @@ public function getNamespaceAutoloaders($namespace) * Register a namespace to autoload * * @param string|array $namespace - * @return Zend_Loader_Autoloader - * @throws \fproject\amf\AmfException + * @return Autoloader + * @throws AmfException */ public function registerNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { - throw new \fproject\amf\AmfException('Invalid namespace provided'); + throw new AmfException('Invalid namespace provided'); } foreach ($namespace as $ns) { @@ -225,15 +217,15 @@ public function registerNamespace($namespace) * Unload a registered autoload namespace * * @param string|array $namespace - * @return Zend_Loader_Autoloader - * @throws \fproject\amf\AmfException + * @return Autoloader + * @throws AmfException */ public function unregisterNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { - throw new \fproject\amf\AmfException('Invalid namespace provided'); + throw new AmfException('Invalid namespace provided'); } foreach ($namespace as $ns) { @@ -259,7 +251,7 @@ public function setZfPath($spec, $version = 'latest') $path = $spec; if (is_array($spec)) { if (!isset($spec['path'])) { - throw new \fproject\amf\AmfException('No path specified for ZF'); + throw new AmfException('No path specified for ZF'); } $path = $spec['path']; if (isset($spec['version'])) { @@ -284,7 +276,7 @@ public function getZfPath() * Get or set the value of the "suppress not found warnings" flag * * @param null|bool $flag - * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise + * @return bool|Autoloader Returns boolean if no argument is passed, object instance otherwise */ public function suppressNotFoundWarnings($flag = null) { @@ -299,7 +291,7 @@ public function suppressNotFoundWarnings($flag = null) * Indicate whether or not this autoloader should be a fallback autoloader * * @param bool $flag - * @return Zend_Loader_Autoloader + * @return Autoloader */ public function setFallbackAutoloader($flag) { @@ -374,9 +366,9 @@ public function getClassAutoloaders($class) /** * Add an autoloader to the beginning of the stack * - * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation + * @param object|array|string $callback PHP callback or AutoloaderInterface implementation * @param string|array $namespace Specific namespace(s) under which to register callback - * @return Zend_Loader_Autoloader + * @return Autoloader */ public function unshiftAutoloader($callback, $namespace = '') { @@ -397,9 +389,9 @@ public function unshiftAutoloader($callback, $namespace = '') /** * Append an autoloader to the autoloader stack * - * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation + * @param object|array|string $callback PHP callback or AutoloaderInterface implementation * @param string|array $namespace Specific namespace(s) under which to register callback - * @return Zend_Loader_Autoloader + * @return Autoloader */ public function pushAutoloader($callback, $namespace = '') { @@ -420,9 +412,9 @@ public function pushAutoloader($callback, $namespace = '') /** * Remove an autoloader from the autoloader stack * - * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation + * @param object|array|string $callback PHP callback or AutoloaderInterface implementation * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader - * @return Zend_Loader_Autoloader + * @return Autoloader */ public function removeAutoloader($callback, $namespace = null) { @@ -481,7 +473,7 @@ protected function _autoload($class) call_user_func($callback, $class); } return $class; - } catch (Zend_Exception $e) { + } catch (AmfException $e) { return false; } } @@ -491,7 +483,7 @@ protected function _autoload($class) * * @param array $autoloaders * @param string $namespace - * @return Zend_Loader_Autoloader + * @return Autoloader */ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '') { @@ -506,7 +498,7 @@ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '') * @param string $path * @param string $version * @return mixed - * @throws \fproject\amf\AmfException + * @throws AmfException */ protected function _getVersionPath($path, $version) { @@ -518,7 +510,7 @@ protected function _getVersionPath($path, $version) $availableVersions = $this->_getAvailableVersions($path, $version); if (empty($availableVersions)) { - throw new \fproject\amf\AmfException('No valid ZF installations discovered'); + throw new AmfException('No valid ZF installations discovered'); } $matchedVersion = array_pop($availableVersions); @@ -530,7 +522,7 @@ protected function _getVersionPath($path, $version) * * @param string $version * @return string "latest", "major", "minor", or "specific" - * @throws \fproject\amf\AmfException if version string contains too many dots + * @throws AmfException if version string contains too many dots */ protected function _getVersionType($version) { @@ -547,7 +539,7 @@ protected function _getVersionType($version) return 'minor'; } if (3 < $count) { - throw new \fproject\amf\AmfException('Invalid version string provided'); + throw new AmfException('Invalid version string provided'); } return 'specific'; } @@ -558,12 +550,12 @@ protected function _getVersionType($version) * @param string $path * @param string $version * @return array - * @throws \fproject\amf\AmfException + * @throws AmfException */ protected function _getAvailableVersions($path, $version) { if (!is_dir($path)) { - throw new \fproject\amf\AmfException('Invalid ZF path provided'); + throw new AmfException('Invalid ZF path provided'); } $path = rtrim($path, '/'); diff --git a/fproject/amf/loader/AutoloaderInterface.php b/fproject/amf/loader/AutoloaderInterface.php new file mode 100644 index 0000000..bdba8f3 --- /dev/null +++ b/fproject/amf/loader/AutoloaderInterface.php @@ -0,0 +1,38 @@ +