diff --git a/CHANGELOG.md b/CHANGELOG.md index de4cd41e..bffd8f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased -For a full diff see [`2.12.0...main`][2.12.0...main]. +For a full diff see [`2.12.1...main`][2.12.1...main]. + +## [`2.12.1`][2.12.1] + +For a full diff see [`2.12.0...2.12.1`][2.12.0...2.12.1]. + +### Fixed + +* Show version of plugin instead of version of `Composer\Console\Application` when running as development dependency ([#643]), by [@localheinz] ## [`2.12.0`][2.12.0] @@ -510,6 +518,7 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0]. [2.10.0]: https://github.com/ergebnis/composer-normalize/releases/tag/2.10.0 [2.11.0]: https://github.com/ergebnis/composer-normalize/releases/tag/2.11.0 [2.12.0]: https://github.com/ergebnis/composer-normalize/releases/tag/2.12.0 +[2.12.1]: https://github.com/ergebnis/composer-normalize/releases/tag/2.12.1 [81bc3a8...0.1.0]: https://github.com/ergebnis/composer-normalize/compare/81bc3a8...0.1.0 [0.1.0...0.2.0]: https://github.com/ergebnis/composer-normalize/compare/0.1.0...0.2.0 @@ -558,7 +567,8 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0]. [2.9.1...2.10.0]: https://github.com/ergebnis/composer-normalize/compare/2.9.1...2.10.0 [2.10.0...2.11.0]: https://github.com/ergebnis/composer-normalize/compare/2.10.0...2.11.0 [2.11.0...2.12.0]: https://github.com/ergebnis/composer-normalize/compare/2.11.0...2.12.0 -[2.12.0...main]: https://github.com/ergebnis/composer-normalize/compare/2.12.0...main +[2.12.0...2.12.1]: https://github.com/ergebnis/composer-normalize/compare/2.12.0...2.12.1 +[2.12.1...main]: https://github.com/ergebnis/composer-normalize/compare/2.12.1...main [#1]: https://github.com/ergebnis/composer-normalize/pull/1 [#2]: https://github.com/ergebnis/composer-normalize/pull/2 @@ -631,6 +641,7 @@ For a full diff see [`81bc3a8...0.1.0`][81bc3a8...0.1.0]. [#634]: https://github.com/ergebnis/composer-normalize/pull/634 [#640]: https://github.com/ergebnis/composer-normalize/pull/640 [#641]: https://github.com/ergebnis/composer-normalize/pull/641 +[#643]: https://github.com/ergebnis/composer-normalize/pull/643 [@core23]: https://github.com/core23 [@dependabot]: https://github.com/dependabot diff --git a/phar/composer-normalize.php b/phar/composer-normalize.php index 78e4326f..9b33ef96 100644 --- a/phar/composer-normalize.php +++ b/phar/composer-normalize.php @@ -11,6 +11,7 @@ * @see https://github.com/ergebnis/composer-normalize */ +use Composer\Console\Application; use Composer\Factory; use Ergebnis\Composer\Normalize; use Ergebnis\Json\Normalizer; @@ -30,7 +31,7 @@ ])) ); -$application = new Normalize\Application(); +$application = new Application(); $application->add($command); diff --git a/src/Command/NormalizeCommand.php b/src/Command/NormalizeCommand.php index 3c08a606..037b7860 100644 --- a/src/Command/NormalizeCommand.php +++ b/src/Command/NormalizeCommand.php @@ -18,6 +18,7 @@ use Composer\Factory; use Composer\IO; use Ergebnis\Composer\Normalize\Exception; +use Ergebnis\Composer\Normalize\Version; use Ergebnis\Json\Normalizer; use Localheinz\Diff; use Symfony\Component\Console; @@ -107,7 +108,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O $io->write([ \sprintf( 'Running %s.', - $this->getApplication()->getLongVersion() + Version::long() ), '', ]); diff --git a/src/Application.php b/src/Version.php similarity index 60% rename from src/Application.php rename to src/Version.php index 853a88cd..e54b811a 100644 --- a/src/Application.php +++ b/src/Version.php @@ -13,53 +13,38 @@ namespace Ergebnis\Composer\Normalize; -use Composer\Console; - /** * @internal */ -final class Application extends Console\Application +final class Version { /** * @see https://github.com/box-project/box/blob/master/doc/configuration.md#pretty-git-tag-placeholder-git * * @var string */ - private $version = '@git@'; + private static $version = '@git@'; - public function getLongVersion(): string + public static function long(): string { + $name = 'ergebnis/composer-normalize'; $attribution = 'by Andreas Möller and contributors'; - $version = $this->getVersion(); + $version = self::$version; - if ('' === $version) { + if ('@' . 'git@' === $version) { return \sprintf( '%s %s', - $this->getName(), + $name, $attribution ); } return \sprintf( '%s %s %s', - $this->getName(), + $name, $version, $attribution ); } - - public function getName(): string - { - return 'ergebnis/composer-normalize'; - } - - public function getVersion(): string - { - if ('@' . 'git@' === $this->version) { - return ''; - } - - return $this->version; - } } diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/AdditionalKeys/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/AdditionalKeys/Test.php index 1592646d..266f55c8 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/AdditionalKeys/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/AdditionalKeys/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/Missing/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/Missing/Test.php index 2e372a86..44ce902f 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/Missing/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/Missing/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotGreaterThanZero/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotGreaterThanZero/Test.php index 397114a3..85a0bbb6 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotGreaterThanZero/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotGreaterThanZero/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotInteger/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotInteger/Test.php index f3c33014..4ce1432e 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotInteger/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentSize/NotInteger/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/Missing/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/Missing/Test.php index 6d3847c4..d92ec744 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/Missing/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/Missing/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotSpaceOrTab/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotSpaceOrTab/Test.php index 1e1b9a1a..eb5466da 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotSpaceOrTab/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotSpaceOrTab/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotString/Test.php b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotString/Test.php index 50614c32..bee2e3c2 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotString/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/NotValid/IndentStyle/NotString/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/Valid/WithOptions/Test.php b/test/Integration/Command/NormalizeCommand/Extra/Valid/WithOptions/Test.php index 63d89c6f..7ea57bca 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/Valid/WithOptions/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/Valid/WithOptions/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Extra/Valid/WithoutOptions/Test.php b/test/Integration/Command/NormalizeCommand/Extra/Valid/WithoutOptions/Test.php index 38704875..d71614d8 100644 --- a/test/Integration/Command/NormalizeCommand/Extra/Valid/WithoutOptions/Test.php +++ b/test/Integration/Command/NormalizeCommand/Extra/Valid/WithoutOptions/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/NotValid/Test.php b/test/Integration/Command/NormalizeCommand/Json/NotValid/Test.php index e9ec3de0..a409743a 100644 --- a/test/Integration/Command/NormalizeCommand/Json/NotValid/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/NotValid/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/AlreadyNormalized/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/AlreadyNormalized/Test.php index d3ffd024..f448f8a5 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/AlreadyNormalized/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/AlreadyNormalized/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/NotYetNormalized/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/NotYetNormalized/Test.php index f0f958e9..e6c7c149 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/NotYetNormalized/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/NotPresent/Json/NotYetNormalized/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/AlreadyNormalized/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/AlreadyNormalized/Test.php index 8751cfaa..2f163bf0 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/AlreadyNormalized/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/AlreadyNormalized/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/FreshAfter/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/FreshAfter/Test.php index b00a6f33..44f2179d 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/FreshAfter/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/FreshAfter/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/NotFreshAfter/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/NotFreshAfter/Test.php index 7c699dc6..ba2049f6 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/NotFreshAfter/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/FreshBefore/Json/NotYetNormalized/Lock/NotFreshAfter/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/AlreadyNormalized/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/AlreadyNormalized/Test.php index d4f3f69e..68cd7d4d 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/AlreadyNormalized/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/AlreadyNormalized/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/NotYetNormalized/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/NotYetNormalized/Test.php index eb59560c..d4d7c2ee 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/NotYetNormalized/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithNoCheckLock/Json/NotYetNormalized/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithoutNoCheckLock/Test.php b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithoutNoCheckLock/Test.php index 65a2806c..03730284 100644 --- a/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithoutNoCheckLock/Test.php +++ b/test/Integration/Command/NormalizeCommand/Json/Valid/Lock/Present/NotFreshBefore/WithoutNoCheckLock/Test.php @@ -22,6 +22,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Normalizer/Throws/Test.php b/test/Integration/Command/NormalizeCommand/Normalizer/Throws/Test.php index f5b7a1a6..10a3db5a 100644 --- a/test/Integration/Command/NormalizeCommand/Normalizer/Throws/Test.php +++ b/test/Integration/Command/NormalizeCommand/Normalizer/Throws/Test.php @@ -27,6 +27,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Integration/Command/NormalizeCommand/Options/NotValid/Test.php b/test/Integration/Command/NormalizeCommand/Options/NotValid/Test.php index d1ffba61..20ac7ebb 100644 --- a/test/Integration/Command/NormalizeCommand/Options/NotValid/Test.php +++ b/test/Integration/Command/NormalizeCommand/Options/NotValid/Test.php @@ -23,6 +23,8 @@ * * @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand * @covers \Ergebnis\Composer\Normalize\NormalizePlugin + * + * @uses \Ergebnis\Composer\Normalize\Version */ final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase { diff --git a/test/Unit/ApplicationTest.php b/test/Unit/VersionTest.php similarity index 60% rename from test/Unit/ApplicationTest.php rename to test/Unit/VersionTest.php index c3abcb35..724a542d 100644 --- a/test/Unit/ApplicationTest.php +++ b/test/Unit/VersionTest.php @@ -13,22 +13,20 @@ namespace Ergebnis\Composer\Normalize\Test\Unit; -use Ergebnis\Composer\Normalize\Application; +use Ergebnis\Composer\Normalize\Version; use PHPUnit\Framework; /** * @internal * - * @covers \Ergebnis\Composer\Normalize\Application + * @covers \Ergebnis\Composer\Normalize\Version */ -final class ApplicationTest extends Framework\TestCase +final class VersionTest extends Framework\TestCase { - public function testGetLongVersionReturnsVersion(): void + public function testLongReturnsVersion(): void { - $application = new Application(); - $expected = 'ergebnis/composer-normalize by Andreas Möller and contributors'; - self::assertSame($expected, $application->getLongVersion()); + self::assertSame($expected, Version::long()); } }