Skip to content

Commit

Permalink
modify custom format (example) to avoid confusion with console standa…
Browse files Browse the repository at this point in the history
…rd format
  • Loading branch information
llaville committed Aug 1, 2024
1 parent 336e44a commit a3003ad
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions tests/fixtures/my-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,28 @@ public function __invoke(array $content): string
} else {
$version = $rootPackage['version'];
}
$entries[] = [$rootPackage['name'], $version];
$entries[] = [$rootPackage['name'], '', $version, ''];

$allRequirements = [
'' => $composerJson['require'],
' (for development)' => $composerJson['require-dev'] ?? [],
'Direct (for production)' => $composerJson['require'],
'Direct (for development)' => $composerJson['require-dev'] ?? [],
];

foreach ($allRequirements as $category => $requirements) {
foreach ($requirements as $req => $constraint) {
if (!empty($constraint)) {
$constraint = sprintf('<comment>%s</comment>', $constraint);
$prefix = '<comment>requires</comment>';
$constraint = sprintf('<comment>requires %s</comment>', $constraint);
} else {
$prefix = '<comment>uses</comment>';
$constraint = '<comment>uses</comment>';
}
$installedPhp['versions'][$req]['prefix'] = $prefix;
if ('php' === $req) {
$entries[] = [sprintf('%s%s %s', $prefix, $category, "$req $constraint"), phpversion()];
$entries[] = [$req, $constraint, phpversion(), $category];
} elseif (str_starts_with($req, 'ext-')) {
$extension = substr($req, 4);
$entries[] = [sprintf('%s%s %s', $prefix, $category, "$req $constraint"), phpversion($extension)];
$entries[] = [$req, $constraint, phpversion($extension), $category];
} else {
$installedPhp['versions'][$req]['constraint'] = $constraint;
$installedPhp['versions'][$req]['category'] = $category;
$installedPhp['versions'][$req]['constraint'] = $constraint;
$installedPhp['versions'][$req]['category'] = $category;
}
}
}
Expand All @@ -68,18 +66,17 @@ public function __invoke(array $content): string
continue;
}
if (isset($values['pretty_version'])) {
$category = $values['category'] ?? '';
$category = $values['category'] ?? 'Transitive';
$constraint = $values['constraint'] ?? '';
$prefix = $values['prefix'] ?? '<comment>uses</comment>';
$entries[] = [sprintf('%s%s %s', $prefix, $category, "$package $constraint"), $values['pretty_version']];
$entries[] = [$package, $constraint, $values['pretty_version'], $category];
} // otherwise, it's a virtual package
}

$output = new BufferedOutput();
$output->setDecorated(true);
$output->writeln('');

$headers = ['Package', 'Version'];
$headers = ['Package', 'Constraint', 'Version', "Dependency's category"];

$table = new Table($output);
$table
Expand Down

0 comments on commit a3003ad

Please sign in to comment.