From 7a0390c606ee9f99d6eb66c4ebf29dfe73bcaa5b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 8 Aug 2018 19:49:05 +0200 Subject: [PATCH] info.panel: composer 1.7.0 lock files as no longer dist and source attributes [Closes #311] --- src/Tracy/assets/Bar/info.panel.phtml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Tracy/assets/Bar/info.panel.phtml b/src/Tracy/assets/Bar/info.panel.phtml index 966215db1..e06507118 100644 --- a/src/Tracy/assets/Bar/info.panel.phtml +++ b/src/Tracy/assets/Bar/info.panel.phtml @@ -49,10 +49,13 @@ $packages = $devPackages = []; if (class_exists('Composer\Autoload\ClassLoader', false)) { $lockFile = dirname((new \ReflectionClass('Composer\Autoload\ClassLoader'))->getFileName()) . '/../../composer.lock'; $composer = @json_decode(file_get_contents($lockFile)); // @ may not exist or be valid - $packages = (array) @$composer->packages; - $devPackages = (array) @$composer->{'packages-dev'}; - usort($packages, function ($a, $b) { return strcmp($a->name, $b->name); }); - usort($devPackages, function ($a, $b) { return strcmp($a->name, $b->name); }); + list($packages, $devPackages) = [(array) @$composer->packages, (array) @$composer->{'packages-dev'}]; // @ keys may not exist + foreach ([&$packages, &$devPackages] as &$items) { + @array_walk($items, function($package) { // @ keys may not exist + $package->hash = $package->source->reference ?: $package->dist->reference; + }, $items); + usort($items, function ($a, $b) { return strcmp($a->name, $b->name); }); + } } ?> @@ -95,7 +98,7 @@ if (class_exists('Composer\Autoload\ClassLoader', false)) { - +
name) ?>version . (strpos($package->version, 'dev') === false ? '' : ' #' . substr(isset($package->source) ? $package->source->reference : $package->dist->reference, 0, 4))) ?>
name) ?>version . (strpos($package->version, 'dev') !== false && $package->hash ? ' #' . substr($package->hash, 0, 4) : '')) ?>
@@ -104,7 +107,7 @@ if (class_exists('Composer\Autoload\ClassLoader', false)) {

Dev Packages

- +
name) ?>version . (strpos($package->version, 'dev') === false ? '' : ' #' . substr(isset($package->source) ? $package->source->reference : $package->dist->reference, 0, 4))) ?>
name) ?>version . (strpos($package->version, 'dev') !== false && $package->hash ? ' #' . substr($package->hash, 0, 4) : '')) ?>