From 0baf3c696a4f2e5adbf34abd5ee4e2907d198dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 27 Dec 2019 10:39:18 +0100 Subject: [PATCH] Enhancement: Show version of ergebnis/composer-normalize --- .github/workflows/continuous-integration.yml | 3 ++ box.json | 1 + composer-require-checker.json | 1 + phar/composer-normalize.php | 10 ++--- phpstan.neon | 1 + src/Application.php | 31 ++++++++++++++++ test/Unit/ApplicationTest.php | 39 ++++++++++++++++++++ 7 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 src/Application.php create mode 100644 test/Unit/ApplicationTest.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d35afde1..25101f70 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -285,6 +285,9 @@ jobs: - name: "Require composer/composer" run: "composer require composer/composer:1.9.1 --no-interaction --no-progress --no-suggest" + - name: "Remove git placeholder configuration with jq" + run: "echo $(cat box.json | jq 'del(.git)') > box.json" + - name: "Validate configuration for humbug/box" run: "phar/box.phar validate box.json" diff --git a/box.json b/box.json index 3728a43e..74e2cb27 100644 --- a/box.json +++ b/box.json @@ -8,6 +8,7 @@ "files": [ "resource/schema.json" ], + "git": "git", "main": "phar/composer-normalize.php", "output": ".build/phar/composer-normalize.phar" } diff --git a/composer-require-checker.json b/composer-require-checker.json index 060e4b14..06864f6a 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -17,6 +17,7 @@ "void", "Composer\\Command\\BaseCommand", "Composer\\Composer", + "Composer\\Console\\Application", "Composer\\Factory", "Composer\\IO\\IOInterface", "Composer\\Json\\JsonFile", diff --git a/phar/composer-normalize.php b/phar/composer-normalize.php index c7d59890..cab495f5 100644 --- a/phar/composer-normalize.php +++ b/phar/composer-normalize.php @@ -11,8 +11,8 @@ * @see https://github.com/ergebnis/composer-normalize */ -use Composer\Console\Application; -use Ergebnis\Composer\Json\Normalizer\ComposerJsonNormalizer; +use Composer\Factory; +use Ergebnis\Composer\Json; use Ergebnis\Composer\Normalize; use Ergebnis\Json\Normalizer; use Ergebnis\Json\Printer; @@ -21,8 +21,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; $command = new Normalize\Command\NormalizeCommand( - new Composer\Factory(), - new ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'), + new Factory(), + new Json\Normalizer\ComposerJsonNormalizer(__DIR__ . '/../resource/schema.json'), new Normalizer\Format\Formatter(new Printer\Printer()), new Diff\Differ(new Diff\Output\StrictUnifiedDiffOutputBuilder([ 'fromFile' => 'original', @@ -30,7 +30,7 @@ ])) ); -$application = new Application(); +$application = new Normalize\Application(); $application->add($command); $application->setDefaultCommand($command->getName()); diff --git a/phpstan.neon b/phpstan.neon index 29b5c204..c3478c8f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,6 +5,7 @@ parameters: ergebnis: classesAllowedToBeExtended: - Composer\Command\BaseCommand + - Composer\Console\Application - LogicException inferPrivatePropertyTypeFromConstructor: true level: max diff --git a/src/Application.php b/src/Application.php new file mode 100644 index 00000000..0e5c3db8 --- /dev/null +++ b/src/Application.php @@ -0,0 +1,31 @@ +%s with ergebnis/composer-normalize @git@', + $this->getName(), + $this->getVersion() + ); + } +} diff --git a/test/Unit/ApplicationTest.php b/test/Unit/ApplicationTest.php new file mode 100644 index 00000000..4e157475 --- /dev/null +++ b/test/Unit/ApplicationTest.php @@ -0,0 +1,39 @@ +%s with ergebnis/composer-normalize @git@', + $composerApplication->getName(), + $composerApplication->getVersion() + ); + + self::assertSame($expected, $application->getLongVersion()); + } +}