PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
← All changes | vendor/composer/InstalledVersions.php +41 -4 1.212.1.0 View file →
@@ -26,8 +26,14 @@
26 26 */
27 27 class InstalledVersions
28 28 {
29 29 /**
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 + /**
30 36 * @var mixed[]|null
31 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
32 38 */
33 39 private static $installed;
@@ -32,8 +38,13 @@
32 38 */
33 39 private static $installed;
34 40
35 41 /**
42 + * @var bool
43 + */
44 + private static $installedIsLocalDir;
45 +
46 + /**
36 47 * @var bool|null
37 48 */
38 49 private static $canGetVendors;
39 50
@@ -308,11 +319,29 @@
308 319 public static function reload($data)
309 320 {
310 321 self::$installed = $data;
311 322 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;
312 329 }
313 330
314 331 /**
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 + /**
315 344 * @return array[]
316 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[]}>}>
317 346 */
318 347 private static function getInstalled()
@@ -321,21 +350,29 @@
321 350 self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
322 351 }
323 352
324 353 $installed = array();
354 + $copiedLocalDir = false;
325 355
326 356 if (self::$canGetVendors) {
357 + $selfDir = self::getSelfDir();
327 358 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
359 + $vendorDir = strtr($vendorDir, '\\', '/');
328 360 if (isset(self::$installedByVendor[$vendorDir])) {
329 361 $installed[] = self::$installedByVendor[$vendorDir];
330 362 } elseif (is_file($vendorDir.'/composer/installed.php')) {
331 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 */
332 364 $required = require $vendorDir.'/composer/installed.php';
333 - $installed[] = self::$installedByVendor[$vendorDir] = $required;
334 - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
335 - self::$installed = $installed[count($installed) - 1];
365 + self::$installedByVendor[$vendorDir] = $required;
366 + $installed[] = $required;
367 + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
368 + self::$installed = $required;
369 + self::$installedIsLocalDir = true;
336 370 }
337 371 }
372 + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
373 + $copiedLocalDir = true;
374 + }
338 375 }
339 376 }
340 377
341 378 if (null === self::$installed) {
@@ -349,9 +386,9 @@
349 386 self::$installed = array();
350 387 }
351 388 }
352 389
353 - if (self::$installed !== array()) {
390 + if (self::$installed !== array() && !$copiedLocalDir) {
354 391 $installed[] = self::$installed;
355 392 }
356 393
357 394 return $installed;