phpstan type fixes
parent
8f24b67c3c
commit
23d1030c73
|
@ -665,11 +665,11 @@ EOF;
|
|||
|
||||
foreach ($package->getIncludePaths() as $includePath) {
|
||||
$includePath = trim($includePath, '/');
|
||||
$includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
|
||||
$includePaths[] = $installPath === '' ? $includePath : $installPath.'/'.$includePath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$includePaths) {
|
||||
if (\count($includePaths) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,9 +197,9 @@ abstract class BaseDependencyCommand extends BaseCommand
|
|||
/**
|
||||
* Assembles and prints a bottom-up table of the dependencies.
|
||||
*
|
||||
* @param array{PackageInterface, Link, mixed}[] $results
|
||||
* @param array{PackageInterface, Link, array<mixed>|false}[] $results
|
||||
*/
|
||||
protected function printTable(OutputInterface $output, $results): void
|
||||
protected function printTable(OutputInterface $output, array $results): void
|
||||
{
|
||||
$table = [];
|
||||
$doubles = [];
|
||||
|
@ -221,13 +221,13 @@ abstract class BaseDependencyCommand extends BaseCommand
|
|||
$packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
|
||||
$nameWithLink = $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
|
||||
$rows[] = [$nameWithLink, $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint())];
|
||||
if ($children) {
|
||||
if (is_array($children)) {
|
||||
$queue = array_merge($queue, $children);
|
||||
}
|
||||
}
|
||||
$results = $queue;
|
||||
$table = array_merge($rows, $table);
|
||||
} while (!empty($results));
|
||||
} while (\count($results) > 0);
|
||||
|
||||
$this->renderTable($table, $output);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ abstract class BaseDependencyCommand extends BaseCommand
|
|||
/**
|
||||
* Recursively prints a tree of the selected results.
|
||||
*
|
||||
* @param array{PackageInterface, Link, mixed[]|bool}[] $results Results to be printed at this level.
|
||||
* @param array{PackageInterface, Link, array<mixed>|false}[] $results Results to be printed at this level.
|
||||
* @param string $prefix Prefix of the current tree level.
|
||||
* @param int $level Current level of recursion.
|
||||
*/
|
||||
|
@ -275,7 +275,7 @@ abstract class BaseDependencyCommand extends BaseCommand
|
|||
$linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
|
||||
$circularWarn = $children === false ? '(circular dependency aborted here)' : '';
|
||||
$this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
|
||||
if ($children) {
|
||||
if (is_array($children)) {
|
||||
$this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class InstalledRepository extends CompositeRepository
|
|||
* @param string[] $packagesFound Used internally when recurring
|
||||
*
|
||||
* @return array[] An associative array of arrays as described above.
|
||||
* @phpstan-return array<array{0: PackageInterface, 1: Link, 2: mixed[]|bool}>
|
||||
* @phpstan-return array<array{0: PackageInterface, 1: Link, 2: array<mixed>|false}>
|
||||
*/
|
||||
public function getDependents($needle, ?ConstraintInterface $constraint = null, bool $invert = false, bool $recurse = true, ?array $packagesFound = null): array
|
||||
{
|
||||
|
@ -137,6 +137,7 @@ class InstalledRepository extends CompositeRepository
|
|||
}
|
||||
}
|
||||
}
|
||||
unset($needle);
|
||||
}
|
||||
|
||||
// Require-dev is only relevant for the root package
|
||||
|
@ -163,7 +164,7 @@ class InstalledRepository extends CompositeRepository
|
|||
}
|
||||
|
||||
// When inverting, we need to check for conflicts of the needles against installed packages
|
||||
if ($invert && in_array($package->getName(), $needles)) {
|
||||
if ($invert && in_array($package->getName(), $needles, true)) {
|
||||
foreach ($package->getConflicts() as $link) {
|
||||
foreach ($this->findPackages($link->getTarget()) as $pkg) {
|
||||
$version = new Constraint('=', $pkg->getVersion());
|
||||
|
@ -176,7 +177,7 @@ class InstalledRepository extends CompositeRepository
|
|||
|
||||
// List conflicts against X as they may explain why the current version was selected, or explain why it is rejected if the conflict matched when inverting
|
||||
foreach ($package->getConflicts() as $link) {
|
||||
if (in_array($link->getTarget(), $needles)) {
|
||||
if (in_array($link->getTarget(), $needles, true)) {
|
||||
foreach ($this->findPackages($link->getTarget()) as $pkg) {
|
||||
$version = new Constraint('=', $pkg->getVersion());
|
||||
if ($link->getConstraint()->matches($version) === $invert) {
|
||||
|
@ -187,7 +188,7 @@ class InstalledRepository extends CompositeRepository
|
|||
}
|
||||
|
||||
// When inverting, we need to check for conflicts of the needles' requirements against installed packages
|
||||
if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
|
||||
if ($invert && $constraint && in_array($package->getName(), $needles, true) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
|
||||
foreach ($package->getRequires() as $link) {
|
||||
if (PlatformRepository::isPlatformPackage($link->getTarget())) {
|
||||
if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
|
||||
|
|
Loading…
Reference in New Issue