Ticket #36335: 36335-custom-autoloader-plugin.diff
File 36335-custom-autoloader-plugin.diff, 39.0 KB (added by , 8 years ago) |
---|
-
src/composer.json
diff --git src/composer.json src/composer.json index 6742c64..09e1287 100644
22 22 "source": "https://core.trac.wordpress.org/browser" 23 23 }, 24 24 "require": { 25 " xrstf/composer-php52": "^1.0"25 "schlessera/composer-wp-autoload": "^1" 26 26 }, 27 27 "scripts": { 28 28 "post-install-cmd": [ 29 " xrstf\\Composer52\\Generator::onPostInstallCmd"29 "WordPress\\ComposerAutoload\\Generator::dump" 30 30 ], 31 31 "post-update-cmd": [ 32 " xrstf\\Composer52\\Generator::onPostInstallCmd"32 "WordPress\\ComposerAutoload\\Generator::dump" 33 33 ], 34 34 "post-autoload-dump": [ 35 " xrstf\\Composer52\\Generator::onPostInstallCmd"35 "WordPress\\ComposerAutoload\\Generator::dump" 36 36 ] 37 37 }, 38 "extra": { 39 "wordpress-autoloader": { 40 "class-root": "ABSPATH", 41 "case-sensitive": false 42 } 43 }, 38 44 "autoload": { 39 45 "classmap": [ 40 46 "wp-includes/", -
src/composer.lock
diff --git src/composer.lock src/composer.lock index b06c1af..8e4c10b 100644
4 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 5 "This file is @generated automatically" 6 6 ], 7 "hash": " a72f57ac77499086388d3fd01787fc07",8 "content-hash": " 4b675f5b2ea4e6f58fcbdf81132e35bb",7 "hash": "1435a145ab49178a87b0f5526d17bbe9", 8 "content-hash": "98e6ce3147f1b052bd0e17517e6d858f", 9 9 "packages": [ 10 10 { 11 "name": " xrstf/composer-php52",12 "version": "v1.0. 20",11 "name": "schlessera/composer-wp-autoload", 12 "version": "v1.0.0", 13 13 "source": { 14 14 "type": "git", 15 "url": "https://github.com/ composer-php52/composer-php52.git",16 "reference": " bd41459d5e27df8d33057842b32377c39e97a5a8"15 "url": "https://github.com/schlessera/composer-wp-autoload.git", 16 "reference": "922dfb27e57ae09b9541de2463fda592110e4f27" 17 17 }, 18 18 "dist": { 19 19 "type": "zip", 20 "url": "https://api.github.com/repos/ composer-php52/composer-php52/zipball/bd41459d5e27df8d33057842b32377c39e97a5a8",21 "reference": " bd41459d5e27df8d33057842b32377c39e97a5a8",20 "url": "https://api.github.com/repos/schlessera/composer-wp-autoload/zipball/922dfb27e57ae09b9541de2463fda592110e4f27", 21 "reference": "922dfb27e57ae09b9541de2463fda592110e4f27", 22 22 "shasum": "" 23 23 }, 24 24 "type": "library", 25 "extra": {26 "branch-alias": {27 "dev-default": "1.x-dev"28 }29 },30 25 "autoload": { 31 "psr- 0": {32 " xrstf\\Composer52": "lib/"26 "psr-4": { 27 "WordPress\\ComposerAutoload\\": "src" 33 28 } 34 29 }, 35 30 "notification-url": "https://packagist.org/downloads/", 36 31 "license": [ 37 32 "MIT" 38 33 ], 39 "time": "2016-04-16 21:52:24" 34 "description": "WordPress Core Autoloader for Composer.", 35 "time": "2016-08-30 10:56:09" 40 36 } 41 37 ], 42 38 "packages-dev": [], -
src/wp-settings.php
diff --git src/wp-settings.php src/wp-settings.php index 93a48be..c8815ad 100644
18 18 define( 'WPINC', 'wp-includes' ); 19 19 20 20 // WordPress Core PHP 5.2-compatible Autoloader 21 require_once( ABSPATH . 'wp-vendor/autoload_ 52.php' );21 require_once( ABSPATH . 'wp-vendor/autoload_wordpress.php' ); 22 22 23 23 // Include files required for initialization. 24 24 require( ABSPATH . WPINC . '/load.php' ); -
deleted file src/wp-vendor/autoload_52.php
diff --git src/wp-vendor/autoload_52.php src/wp-vendor/autoload_52.php deleted file mode 100644 index d664386..0000000
+ - 1 <?php2 3 // autoload_52.php generated by xrstf/composer-php524 5 require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';6 7 return ComposerAutoloaderInit1dd196791ebd0cfea0668c22edc062f9::getLoader(); -
deleted file src/wp-vendor/composer/ClassLoader52.php
diff --git src/wp-vendor/composer/ClassLoader52.php src/wp-vendor/composer/ClassLoader52.php deleted file mode 100644 index d721c7e..0000000
+ - 1 <?php2 /*3 * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de4 *5 * This file is released under the terms of the MIT license. You can find the6 * complete text in the attached LICENSE file or online at:7 *8 * http://www.opensource.org/licenses/mit-license.php9 *10 * --------------------------------------------------------------------------11 *12 * 99% of this is copied as-is from the original Composer source code and is13 * released under MIT license as well. Copyright goes to:14 *15 * - Fabien Potencier <fabien@symfony.com>16 * - Jordi Boggiano <j.boggiano@seld.be>17 */18 19 class xrstf_Composer52_ClassLoader {20 private $prefixes = array();21 private $fallbackDirs = array();22 private $useIncludePath = false;23 private $classMap = array();24 private $classMapAuthoratative = false;25 private $allowUnderscore = false;26 27 /**28 * @param boolean $flag true to allow class names with a leading underscore, false to disable29 */30 public function setAllowUnderscore($flag) {31 $this->allowUnderscore = (boolean) $flag;32 }33 34 /**35 * @return array36 */37 public function getPrefixes() {38 return $this->prefixes;39 }40 41 /**42 * Turns off searching the prefix and fallback directories for classes43 * that have not been registered with the class map.44 *45 * @param bool $classMapAuthoratative46 */47 public function setClassMapAuthoritative($classMapAuthoratative) {48 $this->classMapAuthoratative = $classMapAuthoratative;49 }50 51 /**52 * Should class lookup fail if not found in the current class map?53 *54 * @return bool55 */56 public function getClassMapAuthoratative() {57 return $this->classMapAuthoratative;58 }59 60 /**61 * @return array62 */63 public function getFallbackDirs() {64 return $this->fallbackDirs;65 }66 67 /**68 * @return array69 */70 public function getClassMap() {71 return $this->classMap;72 }73 74 /**75 * @param array $classMap class to filename map76 */77 public function addClassMap(array $classMap) {78 if ($this->classMap) {79 $this->classMap = array_merge($this->classMap, $classMap);80 }81 else {82 $this->classMap = $classMap;83 }84 }85 86 /**87 * Registers a set of classes, merging with any others previously set.88 *89 * @param string $prefix the classes prefix90 * @param array|string $paths the location(s) of the classes91 * @param bool $prepend prepend the location(s)92 */93 public function add($prefix, $paths, $prepend = false) {94 if (!$prefix) {95 if ($prepend) {96 $this->fallbackDirs = array_merge(97 (array) $paths,98 $this->fallbackDirs99 );100 }101 else {102 $this->fallbackDirs = array_merge(103 $this->fallbackDirs,104 (array) $paths105 );106 }107 108 return;109 }110 111 if (!isset($this->prefixes[$prefix])) {112 $this->prefixes[$prefix] = (array) $paths;113 return;114 }115 116 if ($prepend) {117 $this->prefixes[$prefix] = array_merge(118 (array) $paths,119 $this->prefixes[$prefix]120 );121 }122 else {123 $this->prefixes[$prefix] = array_merge(124 $this->prefixes[$prefix],125 (array) $paths126 );127 }128 }129 130 /**131 * Registers a set of classes, replacing any others previously set.132 *133 * @param string $prefix the classes prefix134 * @param array|string $paths the location(s) of the classes135 */136 public function set($prefix, $paths) {137 if (!$prefix) {138 $this->fallbackDirs = (array) $paths;139 return;140 }141 142 $this->prefixes[$prefix] = (array) $paths;143 }144 145 /**146 * Turns on searching the include path for class files.147 *148 * @param bool $useIncludePath149 */150 public function setUseIncludePath($useIncludePath) {151 $this->useIncludePath = $useIncludePath;152 }153 154 /**155 * Can be used to check if the autoloader uses the include path to check156 * for classes.157 *158 * @return bool159 */160 public function getUseIncludePath() {161 return $this->useIncludePath;162 }163 164 /**165 * Registers this instance as an autoloader.166 */167 public function register() {168 spl_autoload_register(array($this, 'loadClass'), true);169 }170 171 /**172 * Unregisters this instance as an autoloader.173 */174 public function unregister() {175 spl_autoload_unregister(array($this, 'loadClass'));176 }177 178 /**179 * Loads the given class or interface.180 *181 * @param string $class the name of the class182 * @return bool|null true, if loaded183 */184 public function loadClass($class) {185 if ($file = $this->findFile($class)) {186 include $file;187 return true;188 }189 }190 191 /**192 * Finds the path to the file where the class is defined.193 *194 * @param string $class the name of the class195 * @return string|null the path, if found196 */197 public function findFile($class) {198 if ('\\' === $class[0]) {199 $class = substr($class, 1);200 }201 202 if (isset($this->classMap[$class])) {203 return $this->classMap[$class];204 }205 elseif ($this->classMapAuthoratative) {206 return false;207 }208 209 $classPath = $this->getClassPath($class);210 211 foreach ($this->prefixes as $prefix => $dirs) {212 if (0 === strpos($class, $prefix)) {213 foreach ($dirs as $dir) {214 if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {215 return $dir.DIRECTORY_SEPARATOR.$classPath;216 }217 }218 }219 }220 221 foreach ($this->fallbackDirs as $dir) {222 if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {223 return $dir.DIRECTORY_SEPARATOR.$classPath;224 }225 }226 227 if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {228 return $file;229 }230 231 return $this->classMap[$class] = false;232 }233 234 private function getClassPath($class) {235 if (false !== $pos = strrpos($class, '\\')) {236 // namespaced class name237 $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;238 $className = substr($class, $pos + 1);239 }240 else {241 // PEAR-like class name242 $classPath = null;243 $className = $class;244 }245 246 $className = str_replace('_', DIRECTORY_SEPARATOR, $className);247 248 // restore the prefix249 if ($this->allowUnderscore && DIRECTORY_SEPARATOR === $className[0]) {250 $className[0] = '_';251 }252 253 $classPath .= $className.'.php';254 255 return $classPath;256 }257 258 public static function resolveIncludePath($classPath) {259 $paths = explode(PATH_SEPARATOR, get_include_path());260 261 foreach ($paths as $path) {262 $path = rtrim($path, '/\\');263 264 if ($file = file_exists($path.DIRECTORY_SEPARATOR.$file)) {265 return $file;266 }267 }268 269 return false;270 }271 } -
src/wp-vendor/composer/autoload_classmap.php
diff --git src/wp-vendor/composer/autoload_classmap.php src/wp-vendor/composer/autoload_classmap.php index 8182131..085acdd 100644
return array( 170 170 'Walker_Nav_Menu_Edit' => $baseDir . '/wp-admin/includes/class-walker-nav-menu-edit.php', 171 171 'Walker_Page' => $baseDir . '/wp-includes/class-walker-page.php', 172 172 'Walker_PageDropdown' => $baseDir . '/wp-includes/class-walker-page-dropdown.php', 173 'WordPress\\ComposerAutoload\\AutoloadGenerator' => $vendorDir . '/schlessera/composer-wp-autoload/src/AutoloadGenerator.php', 174 'WordPress\\ComposerAutoload\\Generator' => $vendorDir . '/schlessera/composer-wp-autoload/src/Generator.php', 173 175 '_WP_Dependency' => $baseDir . '/wp-includes/class-wp-dependency.php', 174 176 '_WP_Editors' => $baseDir . '/wp-includes/class-wp-editor.php', 175 177 '_WP_List_Table_Compat' => $baseDir . '/wp-admin/includes/class-wp-list-table-compat.php', … … return array( 179 181 'ftp_sockets' => $baseDir . '/wp-admin/includes/class-ftp-sockets.php', 180 182 'wp_xmlrpc_server' => $baseDir . '/wp-includes/class-wp-xmlrpc-server.php', 181 183 'wpdb' => $baseDir . '/wp-includes/wp-db.php', 182 'xrstf\\Composer52\\AutoloadGenerator' => $vendorDir . '/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php',183 'xrstf\\Composer52\\Generator' => $vendorDir . '/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php',184 184 ); -
src/wp-vendor/composer/autoload_namespaces.php
diff --git src/wp-vendor/composer/autoload_namespaces.php src/wp-vendor/composer/autoload_namespaces.php index 420e846..b7fc012 100644
$vendorDir = dirname(dirname(__FILE__)); 6 6 $baseDir = dirname($vendorDir); 7 7 8 8 return array( 9 'xrstf\\Composer52' => array($vendorDir . '/xrstf/composer-php52/lib'),10 9 ); -
src/wp-vendor/composer/autoload_psr4.php
diff --git src/wp-vendor/composer/autoload_psr4.php src/wp-vendor/composer/autoload_psr4.php index b265c64..cec9c7b 100644
$vendorDir = dirname(dirname(__FILE__)); 6 6 $baseDir = dirname($vendorDir); 7 7 8 8 return array( 9 'WordPress\\ComposerAutoload\\' => array($vendorDir . '/schlessera/composer-wp-autoload/src'), 9 10 ); -
deleted file src/wp-vendor/composer/autoload_real_52.php
diff --git src/wp-vendor/composer/autoload_real_52.php src/wp-vendor/composer/autoload_real_52.php deleted file mode 100644 index 2531a9f..0000000
+ - 1 <?php2 3 // autoload_real_52.php generated by xrstf/composer-php524 5 class ComposerAutoloaderInit1dd196791ebd0cfea0668c22edc062f9 {6 private static $loader;7 8 public static function loadClassLoader($class) {9 if ('xrstf_Composer52_ClassLoader' === $class) {10 require dirname(__FILE__).'/ClassLoader52.php';11 }12 }13 14 /**15 * @return xrstf_Composer52_ClassLoader16 */17 public static function getLoader() {18 if (null !== self::$loader) {19 return self::$loader;20 }21 22 spl_autoload_register(array('ComposerAutoloaderInit1dd196791ebd0cfea0668c22edc062f9', 'loadClassLoader'), true /*, true */);23 self::$loader = $loader = new xrstf_Composer52_ClassLoader();24 spl_autoload_unregister(array('ComposerAutoloaderInit1dd196791ebd0cfea0668c22edc062f9', 'loadClassLoader'));25 26 $vendorDir = dirname(dirname(__FILE__));27 $baseDir = dirname($vendorDir);28 $dir = dirname(__FILE__);29 30 $map = require $dir.'/autoload_namespaces.php';31 foreach ($map as $namespace => $path) {32 $loader->add($namespace, $path);33 }34 35 $classMap = require $dir.'/autoload_classmap.php';36 if ($classMap) {37 $loader->addClassMap($classMap);38 }39 40 $loader->register(true);41 42 return $loader;43 }44 } -
src/wp-vendor/composer/installed.json
diff --git src/wp-vendor/composer/installed.json src/wp-vendor/composer/installed.json index fa402a9..af752cb 100644
1 1 [ 2 2 { 3 "name": " xrstf/composer-php52",4 "version": "v1.0. 20",5 "version_normalized": "1.0. 20.0",3 "name": "schlessera/composer-wp-autoload", 4 "version": "v1.0.0", 5 "version_normalized": "1.0.0.0", 6 6 "source": { 7 7 "type": "git", 8 "url": "https://github.com/ composer-php52/composer-php52.git",9 "reference": " bd41459d5e27df8d33057842b32377c39e97a5a8"8 "url": "https://github.com/schlessera/composer-wp-autoload.git", 9 "reference": "922dfb27e57ae09b9541de2463fda592110e4f27" 10 10 }, 11 11 "dist": { 12 12 "type": "zip", 13 "url": "https://api.github.com/repos/ composer-php52/composer-php52/zipball/bd41459d5e27df8d33057842b32377c39e97a5a8",14 "reference": " bd41459d5e27df8d33057842b32377c39e97a5a8",13 "url": "https://api.github.com/repos/schlessera/composer-wp-autoload/zipball/922dfb27e57ae09b9541de2463fda592110e4f27", 14 "reference": "922dfb27e57ae09b9541de2463fda592110e4f27", 15 15 "shasum": "" 16 16 }, 17 "time": "2016-0 4-16 21:52:24",17 "time": "2016-08-30 10:56:09", 18 18 "type": "library", 19 "extra": {20 "branch-alias": {21 "dev-default": "1.x-dev"22 }23 },24 19 "installation-source": "dist", 25 20 "autoload": { 26 "psr- 0": {27 " xrstf\\Composer52": "lib/"21 "psr-4": { 22 "WordPress\\ComposerAutoload\\": "src" 28 23 } 29 24 }, 30 25 "notification-url": "https://packagist.org/downloads/", 31 26 "license": [ 32 27 "MIT" 33 ] 28 ], 29 "description": "WordPress Core Autoloader for Composer." 34 30 } 35 31 ] -
deleted file src/wp-vendor/xrstf/composer-php52/LICENSE
diff --git src/wp-vendor/xrstf/composer-php52/LICENSE src/wp-vendor/xrstf/composer-php52/LICENSE deleted file mode 100644 index 0e81028..0000000
+ - 1 Copyright (c) 2013 Christoph Mewes2 3 Permission is hereby granted, free of charge, to any person obtaining a copy4 of this software and associated documentation files (the "Software"), to deal5 in the Software without restriction, including without limitation the rights6 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell7 copies of the Software, and to permit persons to whom the Software is furnished8 to do so, subject to the following conditions:9 10 The above copyright notice and this permission notice shall be included in all11 copies or substantial portions of the Software.12 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN19 THE SOFTWARE. -
deleted file src/wp-vendor/xrstf/composer-php52/README.md
diff --git src/wp-vendor/xrstf/composer-php52/README.md src/wp-vendor/xrstf/composer-php52/README.md deleted file mode 100644 index e0b6cda..0000000
+ - 1 PHP 5.2 Autoloading for Composer2 ================================3 4 This package provides an easy way to get a PHP 5.2 compatible autoloader out of Composer. The generated autoloader is fully compatible to the original and is written into separate files, each ending with `_52.php`.5 6 Legacy7 ------8 9 Please do not use this, if you can avoid it. It's a horrible hack, often breaks and is extremely tied to Composer's interna. This package was originally developed in 2012, when PHP 5.2 was much more common on cheap webhosts.10 11 In 2016, this package has been moved from Bitbucket to a Github organization, because the original developer could no longer reliably maintain it. This is the reason for this legacy package name ``xrstf/...``.12 13 Usage14 -----15 16 In your project's `composer.json`, add the following lines:17 18 ```json19 {20 "require": {21 "xrstf/composer-php52": "1.*"22 },23 "scripts": {24 "post-install-cmd": [25 "xrstf\\Composer52\\Generator::onPostInstallCmd"26 ],27 "post-update-cmd": [28 "xrstf\\Composer52\\Generator::onPostInstallCmd"29 ],30 "post-autoload-dump": [31 "xrstf\\Composer52\\Generator::onPostInstallCmd"32 ]33 }34 }35 ```36 37 After the next update/install, you will have a `vendor/autoload_52.php` file, that you can simply include and use in PHP 5.2 projects. -
deleted file src/wp-vendor/xrstf/composer-php52/composer.json
diff --git src/wp-vendor/xrstf/composer-php52/composer.json src/wp-vendor/xrstf/composer-php52/composer.json deleted file mode 100644 index c6d6a9e..0000000
+ - 1 {2 "name": "xrstf/composer-php52",3 "license": "MIT",4 "support": {5 "source": "https://github.com/composer-php52/composer-php52",6 "issues": "https://github.com/composer-php52/composer-php52/issues"7 },8 "autoload": {9 "psr-0": {10 "xrstf\\Composer52": "lib/"11 }12 },13 "scripts": {14 "post-install-cmd": [15 "xrstf\\Composer52\\Generator::onPostInstallCmd"16 ],17 "post-update-cmd": [18 "xrstf\\Composer52\\Generator::onPostInstallCmd"19 ]20 },21 "extra": {22 "branch-alias": {23 "dev-default": "1.x-dev"24 }25 }26 } -
deleted file src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php
diff --git src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/AutoloadGenerator.php deleted file mode 100644 index 2e93e6f..0000000
+ - 1 <?php2 /*3 * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de4 *5 * This file is released under the terms of the MIT license. You can find the6 * complete text in the attached LICENSE file or online at:7 *8 * http://www.opensource.org/licenses/mit-license.php9 *10 * --------------------------------------------------------------------------11 *12 * 99% of this is copied as-is from the original Composer source code and is13 * released under MIT license as well. Copyright goes to:14 *15 * - Igor Wiedler <igor@wiedler.ch>16 * - Jordi Boggiano <j.boggiano@seld.be>17 */18 19 namespace xrstf\Composer52;20 21 use Composer\Autoload\AutoloadGenerator as BaseGenerator;22 use Composer\Autoload\ClassMapGenerator;23 use Composer\Config;24 use Composer\Installer\InstallationManager;25 use Composer\Package\AliasPackage;26 use Composer\Package\PackageInterface;27 use Composer\Repository\InstalledRepositoryInterface;28 use Composer\Util\Filesystem;29 30 class AutoloadGenerator extends BaseGenerator {31 32 /**33 * @var bool34 */35 private $classMapAuthoritative = false;36 37 public function __construct() {38 // do nothing (but keep this constructor so we can build an instance without the need for an event dispatcher)39 }40 41 /**42 * Whether or not generated autoloader considers the class map43 * authoritative.44 *45 * @param bool $classMapAuthoritative46 */47 public function setClassMapAuthoritative($classMapAuthoritative)48 {49 $this->classMapAuthoritative = (boolean) $classMapAuthoritative;50 }51 52 public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '') {53 if ($this->classMapAuthoritative) {54 // Force scanPsr0Packages when classmap is authoritative55 $scanPsr0Packages = true;56 }57 58 $filesystem = new Filesystem();59 $filesystem->ensureDirectoryExists($config->get('vendor-dir'));60 61 $cwd = getcwd();62 $basePath = $filesystem->normalizePath($cwd);63 $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));64 $targetDir = $vendorPath.'/'.$targetDir;65 $filesystem->ensureDirectoryExists($targetDir);66 67 $useGlobalIncludePath = (bool) $config->get('use-include-path');68 $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';69 $classMapAuthoritative = $config->get('classmap-authoritative');70 71 $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);72 $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);73 74 $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);75 $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);76 77 // add 5.2 compat78 $vendorPathCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);79 $vendorPathToTargetDirCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathToTargetDirCode);80 81 $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());82 $autoloads = $this->parseAutoloads($packageMap, $mainPackage);83 84 // add custom psr-0 autoloading if the root package has a target dir85 $targetDirLoader = null;86 $mainAutoload = $mainPackage->getAutoload();87 if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {88 $levels = count(explode('/', $filesystem->normalizePath($mainPackage->getTargetDir())));89 $prefixes = implode(', ', array_map(function ($prefix) {90 return var_export($prefix, true);91 }, array_keys($mainAutoload['psr-0'])));92 93 $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);94 95 $targetDirLoader = <<<EOF96 97 public static function autoload(\$class) {98 \$dir = $baseDirFromTargetDirCode.'/';99 \$prefixes = array($prefixes);100 101 foreach (\$prefixes as \$prefix) {102 if (0 !== strpos(\$class, \$prefix)) {103 continue;104 }105 106 \$path = explode(DIRECTORY_SEPARATOR, self::getClassPath(\$class));107 \$path = \$dir.implode('/', array_slice(\$path, $levels));108 109 if (!\$path = self::resolveIncludePath(\$path)) {110 return false;111 }112 113 require \$path;114 return true;115 }116 }117 118 EOF;119 }120 121 $filesCode = "";122 $autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));123 foreach ($autoloads['files'] as $functionFile) {124 // don't include file if it is using PHP 5.3+ syntax125 // https://bitbucket.org/xrstf/composer-php52/issue/4126 if ($this->isPHP53($functionFile)) {127 $filesCode .= '// require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile)."; // disabled because of PHP 5.3 syntax\n";128 }129 else {130 $filesCode .= ' require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n";131 }132 }133 134 if (!$suffix) {135 $suffix = md5(uniqid('', true));136 }137 138 $includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode);139 140 file_put_contents($vendorPath.'/autoload_52.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));141 file_put_contents($targetDir.'/autoload_real_52.php', $this->getAutoloadRealFile(true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader));142 143 // use stream_copy_to_stream instead of copy144 // to work around https://bugs.php.net/bug.php?id=64634145 $sourceLoader = fopen(__DIR__.'/ClassLoader.php', 'r');146 $targetLoader = fopen($targetDir.'/ClassLoader52.php', 'w+');147 stream_copy_to_stream($sourceLoader, $targetLoader);148 fclose($sourceLoader);149 fclose($targetLoader);150 unset($sourceLoader, $targetLoader);151 }152 153 protected function isPHP53($file) {154 $tokens = token_get_all(file_get_contents($file));155 $php53 = array(T_DIR, T_GOTO, T_NAMESPACE, T_NS_C, T_NS_SEPARATOR, T_USE);156 157 // PHP 5.4+158 if (defined('T_TRAIT')) {159 $php53[] = T_TRAIT;160 $php53[] = T_TRAIT_C;161 $php53[] = T_TRAIT_C;162 }163 164 // PHP 5.5+165 if (defined('T_FINALLY')) {166 $php53[] = T_FINALLY;167 $php53[] = T_YIELD;168 }169 170 foreach ($tokens as $token) {171 if (is_array($token) && in_array($token[0], $php53)) {172 return true;173 }174 }175 176 return false;177 }178 179 protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode) {180 $includePaths = array();181 182 foreach ($packageMap as $item) {183 list($package, $installPath) = $item;184 185 if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {186 $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));187 }188 189 foreach ($package->getIncludePaths() as $includePath) {190 $includePath = trim($includePath, '/');191 $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;192 }193 }194 195 if (!$includePaths) {196 return;197 }198 199 $includePathsFile = <<<EOF200 <?php201 202 // include_paths_52.php generated by xrstf/composer-php52203 204 \$vendorDir = $vendorPathCode;205 \$baseDir = $appBaseDirCode;206 207 return array(208 209 EOF;210 211 foreach ($includePaths as $path) {212 $includePathsFile .= "\t" . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";213 }214 215 return $includePathsFile . ");\n";216 }217 218 protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) {219 return <<<AUTOLOAD220 <?php221 222 // autoload_52.php generated by xrstf/composer-php52223 224 require_once $vendorPathToTargetDirCode.'/autoload_real_52.php';225 226 return ComposerAutoloaderInit$suffix::getLoader();227 228 AUTOLOAD;229 }230 231 protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000) {232 // TODO the class ComposerAutoloaderInit should be revert to a closure233 // when APC has been fixed:234 // - https://github.com/composer/composer/issues/959235 // - https://bugs.php.net/bug.php?id=52144236 // - https://bugs.php.net/bug.php?id=61576237 // - https://bugs.php.net/bug.php?id=59298238 239 if ($filesCode) {240 $filesCode = "\n\n".rtrim($filesCode);241 }242 243 $file = <<<HEADER244 <?php245 246 // autoload_real_52.php generated by xrstf/composer-php52247 248 class ComposerAutoloaderInit$suffix {249 private static \$loader;250 251 public static function loadClassLoader(\$class) {252 if ('xrstf_Composer52_ClassLoader' === \$class) {253 require dirname(__FILE__).'/ClassLoader52.php';254 }255 }256 257 /**258 * @return xrstf_Composer52_ClassLoader259 */260 public static function getLoader() {261 if (null !== self::\$loader) {262 return self::\$loader;263 }264 265 spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true /*, true */);266 self::\$loader = \$loader = new xrstf_Composer52_ClassLoader();267 spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));268 269 \$vendorDir = $vendorPathCode;270 \$baseDir = $appBaseDirCode;271 \$dir = dirname(__FILE__);272 273 274 HEADER;275 276 if ($useIncludePath) {277 $file .= <<<'INCLUDE_PATH'278 $includePaths = require $dir.'/include_paths.php';279 array_push($includePaths, get_include_path());280 set_include_path(implode(PATH_SEPARATOR, $includePaths));281 282 283 INCLUDE_PATH;284 }285 286 $file .= <<<'PSR0'287 $map = require $dir.'/autoload_namespaces.php';288 foreach ($map as $namespace => $path) {289 $loader->add($namespace, $path);290 }291 292 293 PSR0;294 295 if ($useClassMap) {296 $file .= <<<'CLASSMAP'297 $classMap = require $dir.'/autoload_classmap.php';298 if ($classMap) {299 $loader->addClassMap($classMap);300 }301 302 303 CLASSMAP;304 }305 306 if ($this->classMapAuthoritative) {307 $file .= <<<'CLASSMAPAUTHORITATIVE'308 $loader->setClassMapAuthoritative(true);309 310 CLASSMAPAUTHORITATIVE;311 }312 313 if ($useGlobalIncludePath) {314 $file .= <<<'INCLUDEPATH'315 $loader->setUseIncludePath(true);316 317 318 INCLUDEPATH;319 }320 321 if ($targetDirLoader) {322 $file .= <<<REGISTER_AUTOLOAD323 spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true);324 325 326 REGISTER_AUTOLOAD;327 328 }329 330 $file .= <<<METHOD_FOOTER331 \$loader->register($prependAutoloader);{$filesCode}332 333 return \$loader;334 }335 336 METHOD_FOOTER;337 338 $file .= $targetDirLoader;339 340 return $file . <<<FOOTER341 }342 343 FOOTER;344 345 }346 } -
deleted file src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/ClassLoader.php
diff --git src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/ClassLoader.php src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/ClassLoader.php deleted file mode 100644 index d721c7e..0000000
+ - 1 <?php2 /*3 * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de4 *5 * This file is released under the terms of the MIT license. You can find the6 * complete text in the attached LICENSE file or online at:7 *8 * http://www.opensource.org/licenses/mit-license.php9 *10 * --------------------------------------------------------------------------11 *12 * 99% of this is copied as-is from the original Composer source code and is13 * released under MIT license as well. Copyright goes to:14 *15 * - Fabien Potencier <fabien@symfony.com>16 * - Jordi Boggiano <j.boggiano@seld.be>17 */18 19 class xrstf_Composer52_ClassLoader {20 private $prefixes = array();21 private $fallbackDirs = array();22 private $useIncludePath = false;23 private $classMap = array();24 private $classMapAuthoratative = false;25 private $allowUnderscore = false;26 27 /**28 * @param boolean $flag true to allow class names with a leading underscore, false to disable29 */30 public function setAllowUnderscore($flag) {31 $this->allowUnderscore = (boolean) $flag;32 }33 34 /**35 * @return array36 */37 public function getPrefixes() {38 return $this->prefixes;39 }40 41 /**42 * Turns off searching the prefix and fallback directories for classes43 * that have not been registered with the class map.44 *45 * @param bool $classMapAuthoratative46 */47 public function setClassMapAuthoritative($classMapAuthoratative) {48 $this->classMapAuthoratative = $classMapAuthoratative;49 }50 51 /**52 * Should class lookup fail if not found in the current class map?53 *54 * @return bool55 */56 public function getClassMapAuthoratative() {57 return $this->classMapAuthoratative;58 }59 60 /**61 * @return array62 */63 public function getFallbackDirs() {64 return $this->fallbackDirs;65 }66 67 /**68 * @return array69 */70 public function getClassMap() {71 return $this->classMap;72 }73 74 /**75 * @param array $classMap class to filename map76 */77 public function addClassMap(array $classMap) {78 if ($this->classMap) {79 $this->classMap = array_merge($this->classMap, $classMap);80 }81 else {82 $this->classMap = $classMap;83 }84 }85 86 /**87 * Registers a set of classes, merging with any others previously set.88 *89 * @param string $prefix the classes prefix90 * @param array|string $paths the location(s) of the classes91 * @param bool $prepend prepend the location(s)92 */93 public function add($prefix, $paths, $prepend = false) {94 if (!$prefix) {95 if ($prepend) {96 $this->fallbackDirs = array_merge(97 (array) $paths,98 $this->fallbackDirs99 );100 }101 else {102 $this->fallbackDirs = array_merge(103 $this->fallbackDirs,104 (array) $paths105 );106 }107 108 return;109 }110 111 if (!isset($this->prefixes[$prefix])) {112 $this->prefixes[$prefix] = (array) $paths;113 return;114 }115 116 if ($prepend) {117 $this->prefixes[$prefix] = array_merge(118 (array) $paths,119 $this->prefixes[$prefix]120 );121 }122 else {123 $this->prefixes[$prefix] = array_merge(124 $this->prefixes[$prefix],125 (array) $paths126 );127 }128 }129 130 /**131 * Registers a set of classes, replacing any others previously set.132 *133 * @param string $prefix the classes prefix134 * @param array|string $paths the location(s) of the classes135 */136 public function set($prefix, $paths) {137 if (!$prefix) {138 $this->fallbackDirs = (array) $paths;139 return;140 }141 142 $this->prefixes[$prefix] = (array) $paths;143 }144 145 /**146 * Turns on searching the include path for class files.147 *148 * @param bool $useIncludePath149 */150 public function setUseIncludePath($useIncludePath) {151 $this->useIncludePath = $useIncludePath;152 }153 154 /**155 * Can be used to check if the autoloader uses the include path to check156 * for classes.157 *158 * @return bool159 */160 public function getUseIncludePath() {161 return $this->useIncludePath;162 }163 164 /**165 * Registers this instance as an autoloader.166 */167 public function register() {168 spl_autoload_register(array($this, 'loadClass'), true);169 }170 171 /**172 * Unregisters this instance as an autoloader.173 */174 public function unregister() {175 spl_autoload_unregister(array($this, 'loadClass'));176 }177 178 /**179 * Loads the given class or interface.180 *181 * @param string $class the name of the class182 * @return bool|null true, if loaded183 */184 public function loadClass($class) {185 if ($file = $this->findFile($class)) {186 include $file;187 return true;188 }189 }190 191 /**192 * Finds the path to the file where the class is defined.193 *194 * @param string $class the name of the class195 * @return string|null the path, if found196 */197 public function findFile($class) {198 if ('\\' === $class[0]) {199 $class = substr($class, 1);200 }201 202 if (isset($this->classMap[$class])) {203 return $this->classMap[$class];204 }205 elseif ($this->classMapAuthoratative) {206 return false;207 }208 209 $classPath = $this->getClassPath($class);210 211 foreach ($this->prefixes as $prefix => $dirs) {212 if (0 === strpos($class, $prefix)) {213 foreach ($dirs as $dir) {214 if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {215 return $dir.DIRECTORY_SEPARATOR.$classPath;216 }217 }218 }219 }220 221 foreach ($this->fallbackDirs as $dir) {222 if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {223 return $dir.DIRECTORY_SEPARATOR.$classPath;224 }225 }226 227 if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {228 return $file;229 }230 231 return $this->classMap[$class] = false;232 }233 234 private function getClassPath($class) {235 if (false !== $pos = strrpos($class, '\\')) {236 // namespaced class name237 $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;238 $className = substr($class, $pos + 1);239 }240 else {241 // PEAR-like class name242 $classPath = null;243 $className = $class;244 }245 246 $className = str_replace('_', DIRECTORY_SEPARATOR, $className);247 248 // restore the prefix249 if ($this->allowUnderscore && DIRECTORY_SEPARATOR === $className[0]) {250 $className[0] = '_';251 }252 253 $classPath .= $className.'.php';254 255 return $classPath;256 }257 258 public static function resolveIncludePath($classPath) {259 $paths = explode(PATH_SEPARATOR, get_include_path());260 261 foreach ($paths as $path) {262 $path = rtrim($path, '/\\');263 264 if ($file = file_exists($path.DIRECTORY_SEPARATOR.$file)) {265 return $file;266 }267 }268 269 return false;270 }271 } -
deleted file src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php
diff --git src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php src/wp-vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php deleted file mode 100644 index 7c8af4d..0000000
+ - 1 <?php2 /*3 * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de4 *5 * This file is released under the terms of the MIT license. You can find the6 * complete text in the attached LICENSE file or online at:7 *8 * http://www.opensource.org/licenses/mit-license.php9 */10 11 namespace xrstf\Composer52;12 13 use Composer\Repository\CompositeRepository;14 use Composer\Script\Event;15 16 class Generator {17 public static function onPostInstallCmd(Event $event) {18 $composer = $event->getComposer();19 $installationManager = $composer->getInstallationManager();20 $repoManager = $composer->getRepositoryManager();21 $localRepo = $repoManager->getLocalRepository();22 $package = $composer->getPackage();23 $config = $composer->getConfig();24 25 // We can't gain access to the Command's input object, so we have to look26 // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works27 // (always returns an empty array), nor does Symfony's Console Input, as28 // it expects a full definition of the current command line and we can't29 // provide that.30 31 $args = $_SERVER['argv'];32 $optimize = in_array('-o', $args) || in_array('--optimize-autoloader', $args) || in_array('--optimize', $args);33 34 $suffix = $config->get('autoloader-suffix');35 36 $generator = new AutoloadGenerator();37 $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize, $suffix);38 }39 }