From f83b6b1026db0f00dd947aef3959a24eb921d8d2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 27 May 2024 17:11:31 +0200 Subject: [PATCH] Enable new phpstan option --- phpstan/config.neon | 1 + src/Composer/Command/RequireCommand.php | 2 ++ tests/Composer/Test/Command/LicensesCommandTest.php | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/phpstan/config.neon b/phpstan/config.neon index 6ffdbe68e..6790168b9 100644 --- a/phpstan/config.neon +++ b/phpstan/config.neon @@ -21,6 +21,7 @@ parameters: reportUnmatchedIgnoredErrors: false treatPhpDocTypesAsCertain: false + reportPossiblyNonexistentConstantArrayOffset: true ignoreErrors: # unused parameters diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index b7ee15681..1b6f5e7b8 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -402,6 +402,8 @@ EOT /** * @param array $requirements + * @param 'require'|'require-dev' $requireKey + * @param 'require'|'require-dev' $removeKey * @throws \Exception */ private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, string $requireKey, string $removeKey): int diff --git a/tests/Composer/Test/Command/LicensesCommandTest.php b/tests/Composer/Test/Command/LicensesCommandTest.php index b48e625f3..fa92d5496 100644 --- a/tests/Composer/Test/Command/LicensesCommandTest.php +++ b/tests/Composer/Test/Command/LicensesCommandTest.php @@ -78,6 +78,9 @@ class LicensesCommandTest extends TestCase continue; } + if (!isset($expected[$i])) { + $this->fail('Got more output lines than expected'); + } $this->assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); } } @@ -108,6 +111,9 @@ class LicensesCommandTest extends TestCase continue; } + if (!isset($expected[$i])) { + $this->fail('Got more output lines than expected'); + } $this->assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); } }