PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.90
WindPress – Tailwind CSS integration for WordPress v3.2.90
3.2.90 3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 All 144 releases
← All changes | vendor/composer/InstalledVersions.php +53 -21 3.0.113.2.90 View file →
@@ -24,13 +24,22 @@
24 24 */
25 25 class InstalledVersions
26 26 {
27 27 /**
28 + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
29 + * @internal
30 + */
31 + private static $selfDir = null;
32 + /**
28 33 * @var mixed[]|null
29 34 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
30 35 */
31 36 private static $installed;
32 37 /**
38 + * @var bool
39 + */
40 + private static $installedIsLocalDir;
41 + /**
33 42 * @var bool|null
34 43 */
35 44 private static $canGetVendors;
36 45 /**
@@ -47,14 +56,14 @@
47 56 public static function getInstalledPackages()
48 57 {
49 58 $packages = array();
50 59 foreach (self::getInstalled() as $installed) {
51 - $packages[] = \array_keys($installed['versions']);
60 + $packages[] = array_keys($installed['versions']);
52 61 }
53 62 if (1 === \count($packages)) {
54 63 return $packages[0];
55 64 }
56 - return \array_keys(\array_flip(\call_user_func_array('WindPressDeps\\array_merge', $packages)));
65 + return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
57 66 }
58 67 /**
59 68 * Returns a list of all package names with a specific type e.g. 'library'
60 69 *
@@ -128,18 +137,18 @@
128 137 $ranges = array();
129 138 if (isset($installed['versions'][$packageName]['pretty_version'])) {
130 139 $ranges[] = $installed['versions'][$packageName]['pretty_version'];
131 140 }
132 - if (\array_key_exists('aliases', $installed['versions'][$packageName])) {
133 - $ranges = \array_merge($ranges, $installed['versions'][$packageName]['aliases']);
141 + if (array_key_exists('aliases', $installed['versions'][$packageName])) {
142 + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
134 143 }
135 - if (\array_key_exists('replaced', $installed['versions'][$packageName])) {
136 - $ranges = \array_merge($ranges, $installed['versions'][$packageName]['replaced']);
144 + if (array_key_exists('replaced', $installed['versions'][$packageName])) {
145 + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
137 146 }
138 - if (\array_key_exists('provided', $installed['versions'][$packageName])) {
139 - $ranges = \array_merge($ranges, $installed['versions'][$packageName]['provided']);
147 + if (array_key_exists('provided', $installed['versions'][$packageName])) {
148 + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
140 149 }
141 - return \implode(' || ', $ranges);
150 + return implode(' || ', $ranges);
142 151 }
143 152 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
144 153 }
145 154 /**
@@ -224,14 +233,14 @@
224 233 * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
225 234 */
226 235 public static function getRawData()
227 236 {
228 - @\trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', \E_USER_DEPRECATED);
237 + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', \E_USER_DEPRECATED);
229 238 if (null === self::$installed) {
230 239 // only require the installed.php file if this file is loaded from its dumped location,
231 240 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
232 - if (\substr(__DIR__, -8, 1) !== 'C') {
233 - self::$installed = (include __DIR__ . '/installed.php');
241 + if (substr(__DIR__, -8, 1) !== 'C') {
242 + self::$installed = include __DIR__ . '/installed.php';
234 243 } else {
235 244 self::$installed = array();
236 245 }
237 246 }
@@ -268,10 +277,25 @@
268 277 public static function reload($data)
269 278 {
270 279 self::$installed = $data;
271 280 self::$installedByVendor = array();
281 + // when using reload, we disable the duplicate protection to ensure that self::$installed data is
282 + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
283 + // so we have to assume it does not, and that may result in duplicate data being returned when listing
284 + // all installed packages for example
285 + self::$installedIsLocalDir = \false;
272 286 }
273 287 /**
288 + * @return string
289 + */
290 + private static function getSelfDir()
291 + {
292 + if (self::$selfDir === null) {
293 + self::$selfDir = strtr(__DIR__, '\\', '/');
294 + }
295 + return self::$selfDir;
296 + }
297 + /**
274 298 * @return array[]
275 299 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
276 300 */
277 301 private static function getInstalled()
@@ -276,37 +300,45 @@
276 300 */
277 301 private static function getInstalled()
278 302 {
279 303 if (null === self::$canGetVendors) {
280 - self::$canGetVendors = \method_exists('WindPressDeps\\Composer\\Autoload\\ClassLoader', 'getRegisteredLoaders');
304 + self::$canGetVendors = method_exists('WindPressDeps\Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
281 305 }
282 306 $installed = array();
307 + $copiedLocalDir = \false;
283 308 if (self::$canGetVendors) {
309 + $selfDir = self::getSelfDir();
284 310 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
311 + $vendorDir = strtr($vendorDir, '\\', '/');
285 312 if (isset(self::$installedByVendor[$vendorDir])) {
286 313 $installed[] = self::$installedByVendor[$vendorDir];
287 - } elseif (\is_file($vendorDir . '/composer/installed.php')) {
314 + } elseif (is_file($vendorDir . '/composer/installed.php')) {
288 315 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
289 - $required = (require $vendorDir . '/composer/installed.php');
290 - $installed[] = self::$installedByVendor[$vendorDir] = $required;
291 - if (null === self::$installed && \strtr($vendorDir . '/composer', '\\', '/') === \strtr(__DIR__, '\\', '/')) {
292 - self::$installed = $installed[\count($installed) - 1];
316 + $required = require $vendorDir . '/composer/installed.php';
317 + self::$installedByVendor[$vendorDir] = $required;
318 + $installed[] = $required;
319 + if (self::$installed === null && $vendorDir . '/composer' === $selfDir) {
320 + self::$installed = $required;
321 + self::$installedIsLocalDir = \true;
293 322 }
294 323 }
324 + if (self::$installedIsLocalDir && $vendorDir . '/composer' === $selfDir) {
325 + $copiedLocalDir = \true;
326 + }
295 327 }
296 328 }
297 329 if (null === self::$installed) {
298 330 // only require the installed.php file if this file is loaded from its dumped location,
299 331 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
300 - if (\substr(__DIR__, -8, 1) !== 'C') {
332 + if (substr(__DIR__, -8, 1) !== 'C') {
301 333 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
302 - $required = (require __DIR__ . '/installed.php');
334 + $required = require __DIR__ . '/installed.php';
303 335 self::$installed = $required;
304 336 } else {
305 337 self::$installed = array();
306 338 }
307 339 }
308 - if (self::$installed !== array()) {
340 + if (self::$installed !== array() && !$copiedLocalDir) {
309 341 $installed[] = self::$installed;
310 342 }
311 343 return $installed;
312 344 }