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' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 72 changed files with 435 additions and 3,604 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-loader",
"description": "Zend\\Loader component",
"description": " ",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,26 +9,29 @@
"homepage": "https://github.com/zendframework/zend-loader",
"autoload": {
"psr-4": {
"Zend\\Loader\\": "src/"
"Zend\\Loader": "src/"
}
},
"require": {
"php": ">=5.3.23"
"php": ">=5.3.3"
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
}
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
"suggest": {
"zendframework/zend-stdlib": "Zend\\Stdlib component"
},
"autoload-dev": {
"psr-4": {
"ZendTest\\Loader\\": "test/"
}
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
}
}
65 changes: 37 additions & 28 deletions src/AutoloaderFactory.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/


namespace Zend\Loader;

use ReflectionClass;

require_once __DIR__ . '/SplAutoloader.php';

if (class_exists('Zend\Loader\AutoloaderFactory')) return;

/**
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AutoloaderFactory
{
Expand Down Expand Up @@ -102,15 +91,11 @@ public static function factory($options = null)
);
}

// unfortunately is_subclass_of is broken on some 5.3 versions
// additionally instanceof is also broken for this use case
if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) {
require_once 'Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException(
sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class)
);
}
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)
);
}

if ($class === static::STANDARD_AUTOLOADER) {
Expand Down Expand Up @@ -200,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 @@ -211,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);
}
}
89 changes: 0 additions & 89 deletions src/Broker.php

This file was deleted.

59 changes: 23 additions & 36 deletions src/ClassMapAutoloader.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -28,11 +17,9 @@
* Class-map autoloader
*
* Utilizes class-map files to lookup classfile locations.
*
*
* @catebory Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
*/
class ClassMapAutoloader implements SplAutoloader
{
Expand All @@ -52,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 @@ -66,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 @@ -82,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 @@ -116,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 @@ -134,7 +121,7 @@ public function registerAutoloadMaps($locations)

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

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

/**
* Register the autoloader with spl_autoload registry
*
*
* @return void
*/
public function register()
Expand All @@ -171,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 @@ -203,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
Loading

0 comments on commit 897f6bf

Please sign in to comment.