diff --git a/composer-require-checker.json b/composer-require-checker.json
index 6ec5469b..8a984abd 100644
--- a/composer-require-checker.json
+++ b/composer-require-checker.json
@@ -25,6 +25,7 @@
"Composer\\Plugin\\Capability\\CommandProvider",
"Composer\\Plugin\\Capable",
"Composer\\Plugin\\PluginInterface",
+ "Symfony\\Component\\Console\\Application",
"Symfony\\Component\\Console\\Input\\ArrayInput",
"Symfony\\Component\\Console\\Input\\InputArgument",
"Symfony\\Component\\Console\\Input\\InputInterface",
diff --git a/src/Command/NormalizeCommand.php b/src/Command/NormalizeCommand.php
index 8c6bc1aa..79b76894 100644
--- a/src/Command/NormalizeCommand.php
+++ b/src/Command/NormalizeCommand.php
@@ -106,7 +106,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
$io = $this->getIO();
try {
- $indent = $this->indentFrom($input);
+ $indent = self::indentFrom($input);
} catch (\RuntimeException $exception) {
$io->writeError(\sprintf(
'%s',
@@ -154,7 +154,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
} catch (Normalizer\Exception\OriginalInvalidAccordingToSchemaException $exception) {
$io->writeError('Original composer.json does not match the expected JSON schema:');
- $this->showValidationErrors(
+ self::showValidationErrors(
$io,
...$exception->errors()
);
@@ -163,7 +163,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
} catch (Normalizer\Exception\NormalizedInvalidAccordingToSchemaException $exception) {
$io->writeError('Normalized composer.json does not match the expected JSON schema:');
- $this->showValidationErrors(
+ self::showValidationErrors(
$io,
...$exception->errors()
);
@@ -204,17 +204,15 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
$composerFile
));
- $io->write([
- '',
- '---------- begin diff ---------->',
- ]);
-
- $io->write($this->diff(
+ $diff = $this->differ->diff(
$json->encoded(),
$formatted->encoded()
- ));
+ );
$io->write([
+ '',
+ '---------- begin diff ---------->',
+ self::formatDiff($diff),
'----------- end diff ----------->',
'',
]);
@@ -239,7 +237,8 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
$this->resetComposer();
- return $this->updateLockerInWorkingDirectory(
+ return self::updateLockerInWorkingDirectory(
+ $this->getApplication(),
$output,
\dirname($composerFile)
);
@@ -252,7 +251,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
*
* @return null|Normalizer\Format\Indent
*/
- private function indentFrom(Console\Input\InputInterface $input): ?Normalizer\Format\Indent
+ private static function indentFrom(Console\Input\InputInterface $input): ?Normalizer\Format\Indent
{
/** @var null|string $indentSize */
$indentSize = $input->getOption('indent-size');
@@ -304,7 +303,7 @@ private function indentFrom(Console\Input\InputInterface $input): ?Normalizer\Fo
return $indent;
}
- private function showValidationErrors(IO\IOInterface $io, string ...$errors): void
+ private static function showValidationErrors(IO\IOInterface $io, string ...$errors): void
{
foreach ($errors as $error) {
$io->writeError(\sprintf(
@@ -316,19 +315,8 @@ private function showValidationErrors(IO\IOInterface $io, string ...$errors): vo
$io->writeError('See https://getcomposer.org/doc/04-schema.md for details on the schema');
}
- /**
- * @param string $before
- * @param string $after
- *
- * @return string
- */
- private function diff(string $before, string $after): string
+ private static function formatDiff(string $diff): string
{
- $diff = $this->differ->diff(
- $before,
- $after
- );
-
$lines = \explode(
"\n",
$diff
@@ -363,6 +351,7 @@ private function diff(string $before, string $after): string
/**
* @see https://getcomposer.org/doc/03-cli.md#update
*
+ * @param Console\Application $application
* @param Console\Output\OutputInterface $output
* @param string $workingDirectory
*
@@ -370,11 +359,11 @@ private function diff(string $before, string $after): string
*
* @return int
*/
- private function updateLockerInWorkingDirectory(Console\Output\OutputInterface $output, string $workingDirectory): int
- {
- /** @var Console\Application $application */
- $application = $this->getApplication();
-
+ private static function updateLockerInWorkingDirectory(
+ Console\Application $application,
+ Console\Output\OutputInterface $output,
+ string $workingDirectory
+ ): int {
return $application->run(
new Console\Input\ArrayInput([
'command' => 'update',