← All changes
|
vendor/automattic/jetpack-autoloader/src/AutoloadGenerator.php
+5
-39
3.0.75
→
3.0.78
View file →
| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | * Class AutoloadGenerator. |
| 21 | 21 | */ |
| 22 | 22 | class AutoloadGenerator { |
| 23 | 23 | |
| 24 | - const VERSION = '5.0.22'; | |
| 24 | + const VERSION = '5.0.23'; | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * IO object. |
| 28 | 28 | * |
| @@ -115,46 +115,12 @@ | ||
| 115 | 115 | krsort( $psr0 ); |
| 116 | 116 | krsort( $psr4 ); |
| 117 | 117 | |
| 118 | 118 | return array( |
| 119 | - 'psr-0' => $psr0, | |
| 120 | - 'psr-4' => $psr4, | |
| 121 | - 'classmap' => $classmap, | |
| 122 | - 'files' => $files, | |
| 123 | - 'exclude-from-classmap' => $this->parseExcludeFromClassmap( $mainPackage ), | |
| 124 | - ); | |
| 125 | - } | |
| 126 | - | |
| 127 | - /** | |
| 128 | - * Builds the classmap exclusion patterns from the root package's | |
| 129 | - * `exclude-from-classmap` autoload config. | |
| 130 | - * | |
| 131 | - * Composer honors `exclude-from-classmap` when building its own classmap, but | |
| 132 | - * this generator never passed it through, so the Jetpack classmap could not | |
| 133 | - * exclude anything. Only the root package is honored, matching how Composer | |
| 134 | - * treats the root's excludes as applying to the whole generated classmap. | |
| 135 | - * | |
| 136 | - * @param PackageInterface $mainPackage Main package instance. | |
| 137 | - * | |
| 138 | - * @return string[] Regex fragments (consumed by AutoloadProcessor) matching paths to exclude. | |
| 139 | - */ | |
| 140 | - protected function parseExcludeFromClassmap( PackageInterface $mainPackage ) { | |
| 141 | - $autoload = $mainPackage->getAutoload(); | |
| 142 | - if ( empty( $autoload['exclude-from-classmap'] ) || ! is_array( $autoload['exclude-from-classmap'] ) ) { | |
| 143 | - return array(); | |
| 144 | - } | |
| 145 | - | |
| 146 | - return array_map( | |
| 147 | - function ( $path ) { | |
| 148 | - // Mirror Composer's classmap-exclusion semantics: escape the path, | |
| 149 | - // then re-enable `*`/`**` as single-/multi-segment wildcards. | |
| 150 | - // `{` is the delimiter AutoloadProcessor wraps these fragments in. | |
| 151 | - $pattern = preg_quote( trim( strtr( $path, '\\', '/' ), '/' ), '{' ); | |
| 152 | - $pattern = str_replace( '\\*\\*', '.+?', $pattern ); | |
| 153 | - $pattern = str_replace( '\\*', '[^/]+?', $pattern ); | |
| 154 | - return $pattern; | |
| 155 | - }, | |
| 156 | - $autoload['exclude-from-classmap'] | |
| 119 | + 'psr-0' => $psr0, | |
| 120 | + 'psr-4' => $psr4, | |
| 121 | + 'classmap' => $classmap, | |
| 122 | + 'files' => $files, | |
| 157 | 123 | ); |
| 158 | 124 | } |
| 159 | 125 | |
| 160 | 126 | /** |