Skip to content

Commit

Permalink
qa: resolve errors flagged by Psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
  • Loading branch information
weierophinney committed Sep 7, 2021
1 parent 69bba18 commit 91c1055
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/AbstractDependencyRewriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,21 @@ public function onPreCommandRun(PreCommandRunEvent $event)
return;
}

/** @psalm-var null|array<array-key, string|numeric> $packages */
$packages = $input->getArgument('packages');

// Ensure we have an array of strings
$packages = is_array($packages) ? $packages : [];
$packages = array_map(
function ($value) {
return (string) $value;
},
$packages
);

$input->setArgument(
'packages',
is_array($packages) ? array_map([$this, 'updatePackageArgument'], $packages) : []
array_map([$this, 'updatePackageArgument'], $packages)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyRewriterPluginDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(?RewriterInterface $rewriter = null)
public static function getSubscribedEvents()
{
if (version_compare(PluginInterface::PLUGIN_API_VERSION, '2.0', 'lt')) {
/** @psalm-suppress UndefinedConstant */
/** @psalm-suppress UndefinedConstant,MixedArrayOffset */
return [
InstallerEvents::PRE_DEPENDENCIES_SOLVING => ['onPreDependenciesSolving', 1000],
PackageEvents::PRE_PACKAGE_INSTALL => ['onPrePackageInstallOrUpdate', 1000],
Expand Down
1 change: 0 additions & 1 deletion src/DependencyRewriterV1.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function onPreDependenciesSolving(InstallerEvent $event)
$jobs = $request->getJobs();

foreach ($jobs as $index => $job) {
/** @psalm-var array<string, string> $job */
if (! isset($job['cmd']) || ! in_array($job['cmd'], ['install', 'update'], true)) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions test/DependencyRewriterV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ public function testComposerOptionsArePassedToUpdateLockCommand(
}

/**
* @psalm-suppress MoreSpecificReturnType
* @psalm-return iterable<non-empty-string,array{0:TComposerOptions,1:TComposerOptions}>
*/
public function composerUpdateLockArguments(): iterable
Expand Down

0 comments on commit 91c1055

Please sign in to comment.