Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into acceptHandling
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Http/Header/AbstractAccept.php
	library/Zend/Http/Header/AcceptEncoding.php
	library/Zend/Http/Header/AcceptLanguage.php
	tests/Zend/Http/Header/AcceptCharsetTest.php
	tests/Zend/Http/Header/AcceptEncodingTest.php
	tests/Zend/Http/Header/AcceptLanguageTest.php
	tests/Zend/Http/Header/AcceptTest.php
  • Loading branch information
Freeaqingme committed Jul 14, 2012
6 parents d24d1e5 + 4daeba0 + 660eb19 + 587b0dd + 13e8cbe + 7100033 commit 50b1c92
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 99 deletions.
31 changes: 28 additions & 3 deletions src/AutoloaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Zend\Loader;

use ReflectionClass;

require_once __DIR__ . '/SplAutoloader.php';

if (class_exists('Zend\Loader\AutoloaderFactory')) return;
Expand Down Expand Up @@ -89,8 +91,7 @@ public static function factory($options = null)
);
}

require_once __DIR__ . '/../Stdlib/SubClass.php';
if (!\Zend\Stdlib\SubClass::isSubclassOf($class, 'Zend\Loader\SplAutoloader')) {
if (!self::isSubclassOf($class, 'Zend\Loader\SplAutoloader')) {
require_once 'Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException(
sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class)
Expand Down Expand Up @@ -184,7 +185,7 @@ protected static function getStandardAutoloader()
if (null !== static::$standardAutoloader) {
return static::$standardAutoloader;
}

// Extract the filename from the classname
$stdAutoloader = substr(strrchr(static::STANDARD_AUTOLOADER, '\\'), 1);

Expand All @@ -195,4 +196,28 @@ protected static function getStandardAutoloader()
static::$standardAutoloader = $loader;
return static::$standardAutoloader;
}

/**
* Checks if the object has this class as one of its parents
*
* @see https://bugs.php.net/bug.php?id=53727
* @see https://github.com/zendframework/zf2/pull/1807
*
* @param string $className
* @param string $type
*/
protected static function isSubclassOf($className, $type)
{
if (is_subclass_of($className, $type)) {
return true;
}
if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
return false;
}
if (!interface_exists($type)) {
return false;
}
$r = new ReflectionClass($className);
return $r->implementsInterface($type);
}
}
36 changes: 18 additions & 18 deletions src/ClassMapAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Class-map autoloader
*
* Utilizes class-map files to lookup classfile locations.
*
*
* @catebory Zend
* @package Zend_Loader
*/
Expand All @@ -39,7 +39,7 @@ class ClassMapAutoloader implements SplAutoloader
* Constructor
*
* Create a new instance, and optionally configure the autoloader.
*
*
* @param null|array|\Traversable $options
*/
public function __construct($options = null)
Expand All @@ -53,8 +53,8 @@ public function __construct($options = null)
* Configure the autoloader
*
* Proxies to {@link registerAutoloadMaps()}.
*
* @param array|Traversable $options
*
* @param array|Traversable $options
* @return ClassMapAutoloader
*/
public function setOptions($options)
Expand All @@ -69,10 +69,10 @@ public function setOptions($options)
* An autoload map may be either an associative array, or a file returning
* an associative array.
*
* An autoload map should be an associative array containing
* An autoload map should be an associative array containing
* classname/file pairs.
*
* @param string|array $map
*
* @param string|array $map
* @return ClassMapAutoloader
*/
public function registerAutoloadMap($map)
Expand Down Expand Up @@ -103,8 +103,8 @@ public function registerAutoloadMap($map)

/**
* Register many autoload maps at once
*
* @param array $locations
*
* @param array $locations
* @return ClassMapAutoloader
*/
public function registerAutoloadMaps($locations)
Expand All @@ -121,7 +121,7 @@ public function registerAutoloadMaps($locations)

/**
* Retrieve current autoload map
*
*
* @return array
*/
public function getAutoloadMap()
Expand All @@ -131,8 +131,8 @@ public function getAutoloadMap()

/**
* Defined by Autoloadable
*
* @param string $class
*
* @param string $class
* @return void
*/
public function autoload($class)
Expand All @@ -144,7 +144,7 @@ public function autoload($class)

/**
* Register the autoloader with spl_autoload registry
*
*
* @return void
*/
public function register()
Expand All @@ -158,8 +158,8 @@ public function register()
* If the map has been previously loaded, returns the current instance;
* otherwise, returns whatever was returned by calling include() on the
* location.
*
* @param string $location
*
* @param string $location
* @return ClassMapAutoloader|mixed
* @throws Exception\InvalidArgumentException for nonexistent locations
*/
Expand Down Expand Up @@ -190,16 +190,16 @@ protected function loadMapFromFile($location)
/**
* Resolve the real_path() to a file within a phar.
*
* @see https://bugs.php.net/bug.php?id=52769
* @param string $path
* @see https://bugs.php.net/bug.php?id=52769
* @param string $path
* @return string
*/
public static function realPharPath($path)
{
if (strpos($path, 'phar:///') !== 0) {
return;
}

$parts = explode('/', str_replace(array('/','\\'), '/', substr($path, 8)));
$parts = array_values(array_filter($parts, function($p) { return ($p !== '' && $p !== '.'); }));

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @package Zend_Loader
* @subpackage Exception
*/
class BadMethodCallException extends \BadMethodCallException implements
class BadMethodCallException extends \BadMethodCallException implements
ExceptionInterface
{
}
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* @package Zend_Loader
* @subpackage Exception
*/
class InvalidArgumentException extends \InvalidArgumentException implements
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Exception/MissingResourceNamespaceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* @package Zend_Loader
* @subpackage Exception
*/
class MissingResourceNamespaceException extends \Exception implements
class MissingResourceNamespaceException extends \Exception implements
ExceptionInterface
{}
32 changes: 16 additions & 16 deletions src/PluginClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PluginClassLoader implements PluginClassLocator

/**
* Constructor
*
*
* @param null|array|Traversable $map If provided, seeds the loader with a map
* @return void
*/
Expand All @@ -57,8 +57,8 @@ public function __construct($map = null)
* Add a static map of plugins
*
* A null value will clear the static map.
*
* @param null|array|Traversable $map
*
* @param null|array|Traversable $map
* @return void
*/
public static function addStaticMap($map)
Expand All @@ -78,9 +78,9 @@ public static function addStaticMap($map)

/**
* Register a class to a given short name
*
* @param string $shortName
* @param string $className
*
* @param string $shortName
* @param string $className
* @return PluginClassLoader
*/
public function registerPlugin($shortName, $className)
Expand All @@ -92,17 +92,17 @@ public function registerPlugin($shortName, $className)
/**
* Register many plugins at once
*
* If $map is a string, assumes that the map is the class name of a
* If $map is a string, assumes that the map is the class name of a
* Traversable object (likely a ShortNameLocator); it will then instantiate
* this class and use it to register plugins.
*
* If $map is an array or Traversable object, it will iterate it to
* If $map is an array or Traversable object, it will iterate it to
* register plugin names/classes.
*
* For all other arguments, or if the string $map is not a class or not a
* For all other arguments, or if the string $map is not a class or not a
* Traversable class, an exception will be raised.
*
* @param string|array|Traversable $map
*
* @param string|array|Traversable $map
* @return PluginClassLoader
* @throws Exception\InvalidArgumentException
*/
Expand Down Expand Up @@ -146,8 +146,8 @@ public function registerPlugins($map)

/**
* Unregister a short name lookup
*
* @param mixed $shortName
*
* @param mixed $shortName
* @return PluginClassLoader
*/
public function unregisterPlugin($shortName)
Expand All @@ -161,7 +161,7 @@ public function unregisterPlugin($shortName)

/**
* Get a list of all registered plugins
*
*
* @return array|Traversable
*/
public function getRegisteredPlugins()
Expand Down Expand Up @@ -209,9 +209,9 @@ public function load($name)
/**
* Defined by IteratorAggregate
*
* Returns an instance of ArrayIterator, containing a map of
* Returns an instance of ArrayIterator, containing a map of
* all plugins
*
*
* @return Iterator
*/
public function getIterator()
Expand Down
12 changes: 6 additions & 6 deletions src/PluginClassLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ interface PluginClassLocator extends ShortNameLocator, \IteratorAggregate
{
/**
* Register a class to a given short name
*
* @param string $shortName
* @param string $className
*
* @param string $shortName
* @param string $className
* @return PluginClassLocator
*/
public function registerPlugin($shortName, $className);

/**
* Unregister a short name lookup
*
* @param mixed $shortName
*
* @param mixed $shortName
* @return void
*/
public function unregisterPlugin($shortName);

/**
* Get a list of all registered plugins
*
*
* @return array|Traversable
*/
public function getRegisteredPlugins();
Expand Down
Loading

0 comments on commit 50b1c92

Please sign in to comment.