PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/composer/InstalledVersions.php +14 -60 4.0.43.7.1 View file →
@@ -20,31 +20,18 @@
20 20 *
21 21 * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22 22 *
23 23 * To require its presence, you can require `composer-runtime-api ^2.0`
24 - *
25 - * @final
26 24 */
27 25 class InstalledVersions
28 26 {
29 27 /**
30 - * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
31 - * @internal
32 - */
33 - private static $selfDir = null;
34 -
35 - /**
36 28 * @var mixed[]|null
37 - * @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
29 + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
38 30 */
39 31 private static $installed;
40 32
41 33 /**
42 - * @var bool
43 - */
44 - private static $installedIsLocalDir;
45 -
46 - /**
47 34 * @var bool|null
48 35 */
49 36 private static $canGetVendors;
50 37
@@ -49,9 +36,9 @@
49 36 private static $canGetVendors;
50 37
51 38 /**
52 39 * @var array[]
53 - * @psalm-var array<string, 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[]}>}>
40 + * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
54 41 */
55 42 private static $installedByVendor = array();
56 43
57 44 /**
@@ -108,9 +95,9 @@
108 95 public static function isInstalled($packageName, $includeDevRequirements = true)
109 96 {
110 97 foreach (self::getInstalled() as $installed) {
111 98 if (isset($installed['versions'][$packageName])) {
112 - return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
99 + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
113 100 }
114 101 }
115 102
116 103 return false;
@@ -129,9 +116,9 @@
129 116 * @return bool
130 117 */
131 118 public static function satisfies(VersionParser $parser, $packageName, $constraint)
132 119 {
133 - $constraint = $parser->parseConstraints((string) $constraint);
120 + $constraint = $parser->parseConstraints($constraint);
134 121 $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
135 122
136 123 return $provided->matches($constraint);
137 124 }
@@ -253,9 +240,9 @@
253 240 }
254 241
255 242 /**
256 243 * @return array
257 - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
244 + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
258 245 */
259 246 public static function getRootPackage()
260 247 {
261 248 $installed = self::getInstalled();
@@ -267,9 +254,9 @@
267 254 * Returns the raw installed.php data for custom implementations
268 255 *
269 256 * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
270 257 * @return array[]
271 - * @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[]}>}
258 + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
272 259 */
273 260 public static function getRawData()
274 261 {
275 262 @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);
@@ -290,9 +277,9 @@
290 277 /**
291 278 * Returns the raw data of all installed.php which are currently loaded for custom implementations
292 279 *
293 280 * @return array[]
294 - * @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[]}>}>
281 + * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
295 282 */
296 283 public static function getAllRawData()
297 284 {
298 285 return self::getInstalled();
@@ -313,37 +300,19 @@
313 300 *
314 301 * @param array[] $data A vendor/composer/installed.php data set
315 302 * @return void
316 303 *
317 - * @psalm-param 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[]}>} $data
304 + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
318 305 */
319 306 public static function reload($data)
320 307 {
321 308 self::$installed = $data;
322 309 self::$installedByVendor = array();
323 -
324 - // when using reload, we disable the duplicate protection to ensure that self::$installed data is
325 - // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
326 - // so we have to assume it does not, and that may result in duplicate data being returned when listing
327 - // all installed packages for example
328 - self::$installedIsLocalDir = false;
329 310 }
330 311
331 312 /**
332 - * @return string
333 - */
334 - private static function getSelfDir()
335 - {
336 - if (self::$selfDir === null) {
337 - self::$selfDir = strtr(__DIR__, '\\', '/');
338 - }
339 -
340 - return self::$selfDir;
341 - }
342 -
343 - /**
344 313 * @return array[]
345 - * @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[]}>}>
314 + * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
346 315 */
347 316 private static function getInstalled()
348 317 {
349 318 if (null === self::$canGetVendors) {
@@ -350,29 +319,19 @@
350 319 self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
351 320 }
352 321
353 322 $installed = array();
354 - $copiedLocalDir = false;
355 323
356 324 if (self::$canGetVendors) {
357 - $selfDir = self::getSelfDir();
358 325 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
359 - $vendorDir = strtr($vendorDir, '\\', '/');
360 326 if (isset(self::$installedByVendor[$vendorDir])) {
361 327 $installed[] = self::$installedByVendor[$vendorDir];
362 328 } elseif (is_file($vendorDir.'/composer/installed.php')) {
363 - /** @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 */
364 - $required = require $vendorDir.'/composer/installed.php';
365 - self::$installedByVendor[$vendorDir] = $required;
366 - $installed[] = $required;
367 - if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
368 - self::$installed = $required;
369 - self::$installedIsLocalDir = true;
329 + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
330 + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
331 + self::$installed = $installed[count($installed) - 1];
370 332 }
371 333 }
372 - if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
373 - $copiedLocalDir = true;
374 - }
375 334 }
376 335 }
377 336
378 337 if (null === self::$installed) {
@@ -378,19 +337,14 @@
378 337 if (null === self::$installed) {
379 338 // only require the installed.php file if this file is loaded from its dumped location,
380 339 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
381 340 if (substr(__DIR__, -8, 1) !== 'C') {
382 - /** @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 */
383 - $required = require __DIR__ . '/installed.php';
384 - self::$installed = $required;
341 + self::$installed = require __DIR__ . '/installed.php';
385 342 } else {
386 343 self::$installed = array();
387 344 }
388 345 }
389 -
390 - if (self::$installed !== array() && !$copiedLocalDir) {
391 - $installed[] = self::$installed;
392 - }
346 + $installed[] = self::$installed;
393 347
394 348 return $installed;
395 349 }
396 350 }