Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Loader] Delete legacy Zend\Loader and related resources.

  • Loading branch information...
commit ba3f86f6ec16205e5403cc208e0b32366baa948c 1 parent e8eea2d
@Maks3w Maks3w authored
View
170 library/Zend/Loader.php
@@ -1,170 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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
- */
-
-namespace Zend;
-
-/**
- * Static methods for loading classes and files.
- *
- * @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
- */
-class Loader
-{
- /**
- * Loads a PHP file. This is a wrapper for PHP's include() function.
- *
- * $filename must be the complete filename, including any
- * extension such as ".php". Note that a security check is performed that
- * does not permit extended characters in the filename. This method is
- * intended for loading Zend Framework files.
- *
- * If $dirs is a string or an array, it will search the directories
- * in the order supplied, and attempt to load the first matching file.
- *
- * If the file was not found in the $dirs, or if no $dirs were specified,
- * it will attempt to load it from PHP's include_path.
- *
- * If $once is TRUE, it will use include_once() instead of include().
- *
- * @param string $filename
- * @param string|array $dirs - OPTIONAL either a path or array of paths
- * to search.
- * @param boolean $once
- * @return boolean
- * @throws Zend\Loader\Exception\SecurityException
- */
- public static function loadFile($filename, $dirs = null, $once = false)
- {
- self::_securityCheck($filename);
-
- /**
- * Search in provided directories, as well as include_path
- */
- $incPath = false;
- if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
- if (is_array($dirs)) {
- $dirs = implode(PATH_SEPARATOR, $dirs);
- }
- $incPath = get_include_path();
- set_include_path($dirs . PATH_SEPARATOR . $incPath);
- }
-
- /**
- * Try finding for the plain filename in the include_path.
- */
- if ($once) {
- include_once $filename;
- } else {
- include $filename;
- }
-
- /**
- * If searching in directories, reset include_path
- */
- if ($incPath) {
- set_include_path($incPath);
- }
-
- return true;
- }
-
- /**
- * Returns TRUE if the $filename is readable, or FALSE otherwise.
- * This function uses the PHP include_path, where PHP's is_readable()
- * does not.
- *
- * @param string $filename
- * @return boolean
- */
- public static function isReadable($filename)
- {
- return (bool)stream_resolve_include_path($filename);
- }
-
- /**
- * Explode an include path into an array
- *
- * If no path provided, uses current include_path. Works around issues that
- * occur when the path includes stream schemas.
- *
- * @param string|null $path
- * @return array
- */
- public static function explodeIncludePath($path = null)
- {
- if (null === $path) {
- $path = get_include_path();
- }
-
- if (PATH_SEPARATOR == ':') {
- // On *nix systems, include_paths which include paths with a stream
- // schema cannot be safely explode'd, so we have to be a bit more
- // intelligent in the approach.
- $paths = preg_split('#:(?!//)#', $path);
- } else {
- $paths = explode(PATH_SEPARATOR, $path);
- }
- return $paths;
- }
-
- /**
- * Ensure that filename does not contain exploits
- *
- * @param string $filename
- * @return void
- * @throws Zend\Loader\Exception\SecurityException
- */
- protected static function _securityCheck($filename)
- {
- /**
- * Security check
- */
- if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
- require_once __DIR__ . '/Loader/Exception/SecurityException.php';
- throw new Loader\Exception\SecurityException('Illegal character in filename');
- }
- }
-
- /**
- * Attempt to include() the file.
- *
- * include() is not prefixed with the @ operator because if
- * the file is loaded and contains a parse error, execution
- * will halt silently and this is difficult to debug.
- *
- * Always set display_errors = Off on production servers!
- *
- * @param string $filespec
- * @param boolean $once
- * @return boolean
- * @deprecated Since 1.5.0; use loadFile() instead
- */
- protected static function _includeFile($filespec, $once = false)
- {
- if ($once) {
- return include_once $filespec;
- } else {
- return include $filespec ;
- }
- }
-}
View
204 tests/Zend/LoaderTest.php
@@ -1,204 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-namespace ZendTest;
-
-use stdClass,
- Phar,
- Zend\Loader;
-
-/**
- * @category Zend
- * @package Loader
- * @subpackage UnitTests
- * @group 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
- */
-class LoaderTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- // Store original autoloaders
- $this->loaders = spl_autoload_functions();
- if (!is_array($this->loaders)) {
- // spl_autoload_functions does not return empty array when no
- // autoloaders registered...
- $this->loaders = array();
- }
-
- // Store original include_path
- $this->includePath = get_include_path();
-
- $this->error = null;
- $this->errorHandler = null;
- }
-
- public function tearDown()
- {
- if ($this->errorHandler !== null) {
- restore_error_handler();
- }
-
- // Restore original autoloaders
- $loaders = spl_autoload_functions();
- if (is_array($loaders)) {
- foreach ($loaders as $loader) {
- spl_autoload_unregister($loader);
- }
- }
-
- foreach ($this->loaders as $loader) {
- spl_autoload_register($loader);
- }
-
- // Restore original include_path
- set_include_path($this->includePath);
- }
-
- public function setErrorHandler()
- {
- set_error_handler(array($this, 'handleErrors'), E_USER_NOTICE);
- $this->errorHandler = true;
- }
-
- public function handleErrors($errno, $errstr)
- {
- $this->error = $errstr;
- }
-
- /**
- * Tests that loadFile() finds a file in the include_path when $dirs is null
- */
- public function testLoaderFileIncludePathEmptyDirs()
- {
- $saveIncludePath = get_include_path();
- set_include_path(implode(array($saveIncludePath, implode(array(__DIR__, '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR));
-
- $this->assertTrue(Loader::loadFile('Class3.php', null));
-
- set_include_path($saveIncludePath);
- }
-
- /**
- * Tests that loadFile() finds a file in the include_path when $dirs is non-null
- * This was not working vis-a-vis ZF-1174
- */
- public function testLoaderFileIncludePathNonEmptyDirs()
- {
- $saveIncludePath = get_include_path();
- set_include_path(implode(array($saveIncludePath, implode(array(__DIR__, '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR));
-
- $this->assertTrue(Loader::loadFile('Class4.php', implode(PATH_SEPARATOR, array('foo', 'bar'))));
-
- set_include_path($saveIncludePath);
- }
-
- /**
- * Tests that isReadable works
- */
- public function testLoaderIsReadable()
- {
- $this->assertTrue(Loader::isReadable(__FILE__));
- $this->assertFalse(Loader::isReadable(__FILE__ . '.foobaar'));
-
- // test that a file in include_path gets loaded, see ZF-2985
- $this->assertTrue(Loader::isReadable('Zend/Version.php'), get_include_path());
- }
-
- /**
- * @group ZF-7271
- * @group ZF-8913
- */
- public function testIsReadableShouldHonorStreamDefinitions()
- {
- $pharFile = __DIR__ . '/_files/Zend_LoaderTest.phar';
- $phar = new Phar($pharFile, 0, 'zlt.phar');
- $incPath = 'phar://zlt.phar'
- . PATH_SEPARATOR . $this->includePath;
- set_include_path($incPath);
- $this->assertTrue(Loader::isReadable('User.php'));
- unset($phar);
- }
-
- /**
- * @group ZF-8913
- */
- public function testIsReadableShouldNotLockWhenTestingForNonExistantFileInPhar()
- {
- if (ini_get('phar.readonly')) {
- $this->markTestSkipped(
- 'creating phar archive is disabled by the php.ini setting "phar.readonly"'
- );
- }
-
- $pharFile = __DIR__ . '/_files/LoaderTest.phar';
- $phar = new Phar($pharFile, 0, 'zlt.phar');
- $incPath = 'phar://zlt.phar'
- . PATH_SEPARATOR . $this->includePath;
- set_include_path($incPath);
- $this->assertFalse(Loader::isReadable('does-not-exist'));
- unset($phar);
- }
-
- /**
- * @group ZF-7271
- */
- public function testExplodeIncludePathProperlyIdentifiesStreamSchemes()
- {
- if (PATH_SEPARATOR != ':') {
- $this->markTestSkipped('This test only works for platforms where the path separator is not ":"');
- }
- $path = 'phar://zlt.phar:/var/www:.:filter://[a-z]:glob://*';
- $paths = Loader::explodeIncludePath($path);
- $this->assertSame(array(
- 'phar://zlt.phar',
- '/var/www',
- '.',
- 'filter://[a-z]',
- 'glob://*',
- ), $paths);
- }
-
- /**
- * @group ZF-9100
- */
- public function testIsReadableShouldReturnTrueForAbsolutePaths()
- {
- set_include_path(__DIR__ . '../../../');
- $path = __DIR__;
- $this->assertTrue(Loader::isReadable($path));
- }
-
- /**
- * @group ZF-9263
- * @group ZF-9166
- * @group ZF-9306
- */
- public function testIsReadableShouldFailEarlyWhenProvidedInvalidWindowsAbsolutePath()
- {
- if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
- $this->markTestSkipped('Windows-only test');
- }
- $path = 'C:/this/file/should/not/exist.php';
- $this->assertFalse(Loader::isReadable($path));
- }
-}
View
BIN  tests/Zend/_files/Zend_LoaderTest.phar
Binary file not shown
View
33 tests/Zend/_files/_testDir1/Class1.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadClassValid()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Class1
-{
-}
View
33 tests/Zend/_files/_testDir1/Class1/Subclass2.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadClassValid()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Class1_Subclass2
-{
-}
View
33 tests/Zend/_files/_testDir1/Class3.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadClassValid()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Class3
-{
-}
View
33 tests/Zend/_files/_testDir1/Class4.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadClassValid()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Class4
-{
-}
View
30 tests/Zend/_files/_testDir1/ClassNonexistent.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty file that is used in unit testing by ZendTest::testLoadClassNonexistent()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
View
33 tests/Zend/_files/_testDir1/Interface1.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadInterfaceValid()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-interface Interface1
-{
-}
View
33 tests/Zend/_files/_testDir2/Class2.php
@@ -1,33 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * 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 UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Empty class that is used in unit testing by ZendTest::testLoadClassSearchDirs()
- *
- * @category Zend
- * @package Zend_Loader
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Class2
-{
-}
Please sign in to comment.
Something went wrong with that request. Please try again.