From d1996ac62f38ecc33bf9d8699e2caee7fc6f7d39 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 4 May 2022 15:18:33 +0200 Subject: [PATCH 1/3] Explicitly configure allow-plugins --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index 552f291..ba197d4 100644 --- a/composer.json +++ b/composer.json @@ -32,5 +32,11 @@ "classmap": [ "test/Functional/Fixtures/TestKernel.php" ] + }, + "config": { + "allow-plugins": { + "hostnet/*": true, + "dealerdirect/phpcodesniffer-composer-installer": false + } } } From 6d7dad4e0a952d30892e2c17f4646bed6caa9b87 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 4 May 2022 15:19:05 +0200 Subject: [PATCH 2/3] Enable phpcs in github workflow --- .github/workflows/main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fb593e5..6a0941d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,3 +27,5 @@ jobs: run: composer install --no-progress --prefer-dist --optimize-autoloader - name: phpunit run: php vendor/bin/phpunit + - name: phpcs + run: php vendor/bin/phpcs From 41da694d9a8036bf8aaaaaa892c2a9171168310f Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 4 May 2022 15:22:48 +0200 Subject: [PATCH 3/3] Update phpcs-tool to 9.1.0 with Hostnet-Level-1 --- composer.json | 2 +- phpcs.xml.dist | 2 +- .../EnumTranslationCompilerPass.php | 4 ++-- .../EnumTranslationCompilerPassTest.php | 10 +++++----- test/Functional/Fixtures/Enum/PostStatus.php | 8 ++++---- test/Functional/Fixtures/Enum/ReplyStatus.php | 4 ++-- test/HostnetEntityTranslationBundleTest.php | 2 +- test/Mock/MockEnum.php | 6 +++--- test/MockArray/MockArrayEnum.php | 6 +++--- test/MockNoArray/MockNoArray.php | 6 +++--- test/MockNoTrans/MockNoTransEnum.php | 6 +++--- test/MockXml/MockXmlEnum.php | 6 +++--- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index ba197d4..c584589 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "symfony/yaml": "^4.4|^5.0" }, "require-dev": { - "hostnet/phpcs-tool": "^8.3", + "hostnet/phpcs-tool": "^9.1.0", "phpunit/phpunit": "^9.5.6", "symfony/finder": "^5.0" }, diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d229215..e8b4ba5 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,5 +2,5 @@ test/Functional/Fixtures/cache/ test/Functional/Fixtures/TestKernel.php - + diff --git a/src/DependencyInjection/EnumTranslationCompilerPass.php b/src/DependencyInjection/EnumTranslationCompilerPass.php index 449669c..7b00cba 100644 --- a/src/DependencyInjection/EnumTranslationCompilerPass.php +++ b/src/DependencyInjection/EnumTranslationCompilerPass.php @@ -78,7 +78,7 @@ protected function registerEnums(ContainerBuilder $container, array $enum_files) // convert the flatten keys into a list of enum classes. $enums = array_unique(array_map(function ($str) { - $parts = explode(".", $str); + $parts = explode('.', $str); array_pop($parts); return preg_replace_callback( @@ -86,7 +86,7 @@ protected function registerEnums(ContainerBuilder $container, array $enum_files) function ($matches) { return strtoupper($matches[1]); }, - implode("\\", array_map('ucfirst', $parts)) + implode('\\', array_map('ucfirst', $parts)) ); }, array_keys($this->flattenKeys($translations)))); diff --git a/test/DependencyInjection/EnumTranslationCompilerPassTest.php b/test/DependencyInjection/EnumTranslationCompilerPassTest.php index 7405d31..8663eed 100644 --- a/test/DependencyInjection/EnumTranslationCompilerPassTest.php +++ b/test/DependencyInjection/EnumTranslationCompilerPassTest.php @@ -19,7 +19,7 @@ class EnumTranslationCompilerPassTest extends TestCase /** * @dataProvider processLoadYamlFilesProvider */ - public function testProcessLoadYamlFiles($resource_path) + public function testProcessLoadYamlFiles($resource_path): void { $resources = realpath($resource_path); $container = new ContainerBuilder(); @@ -44,7 +44,7 @@ public function processLoadYamlFilesProvider() yield [__DIR__ . '/../Mock/Resources/translations/enum.en.yaml']; } - public function testProcess() + public function testProcess(): void { $resources = realpath(__DIR__ . '/../Mock/Resources/translations/enum.en.yml'); $container = new ContainerBuilder(); @@ -63,7 +63,7 @@ public function testProcess() $this->assertEquals(['addResource', ['enum', $resources, 'en', MockEnum::class]], $calls[0]); } - public function testProcessNotYml() + public function testProcessNotYml(): void { $resources = realpath(__DIR__ . '/../MockXml/Resources/translations/enum.en.xml'); $container = new ContainerBuilder(); @@ -80,7 +80,7 @@ public function testProcessNotYml() $pass->process($container); } - public function testProcessNoTrans() + public function testProcessNoTrans(): void { $container = new ContainerBuilder(); $translator = new Definition(); @@ -98,7 +98,7 @@ public function testProcessNoTrans() $this->assertEquals(0, count($calls)); } - public function testProcessNoArray() + public function testProcessNoArray(): void { $resources = realpath(__DIR__ . '/../MockNoArray/Resources/translations/enum.en.yml'); $container = new ContainerBuilder(); diff --git a/test/Functional/Fixtures/Enum/PostStatus.php b/test/Functional/Fixtures/Enum/PostStatus.php index 653760e..1659741 100644 --- a/test/Functional/Fixtures/Enum/PostStatus.php +++ b/test/Functional/Fixtures/Enum/PostStatus.php @@ -8,10 +8,10 @@ final class PostStatus { - const AWAITING_APPROVAL = 'awaiting approval'; - const VISIBLE = 'visible'; - const DELETED = 'deleted'; - const HIDDEN = 'hidden'; + public const AWAITING_APPROVAL = 'awaiting approval'; + public const VISIBLE = 'visible'; + public const DELETED = 'deleted'; + public const HIDDEN = 'hidden'; /** * @codeCoverageIgnore private by design because this is an ENUM class diff --git a/test/Functional/Fixtures/Enum/ReplyStatus.php b/test/Functional/Fixtures/Enum/ReplyStatus.php index 4900fa9..bd7d692 100644 --- a/test/Functional/Fixtures/Enum/ReplyStatus.php +++ b/test/Functional/Fixtures/Enum/ReplyStatus.php @@ -8,8 +8,8 @@ final class ReplyStatus { - const CLOSED = 0; - const OPEN = 1; + public const CLOSED = 0; + public const OPEN = 1; /** * @codeCoverageIgnore private by design because this is an ENUM class diff --git a/test/HostnetEntityTranslationBundleTest.php b/test/HostnetEntityTranslationBundleTest.php index 0501cb0..b166ec2 100644 --- a/test/HostnetEntityTranslationBundleTest.php +++ b/test/HostnetEntityTranslationBundleTest.php @@ -15,7 +15,7 @@ */ class HostnetEntityTranslationBundleTest extends TestCase { - public function testBuild() + public function testBuild(): void { $container = new ContainerBuilder(); diff --git a/test/Mock/MockEnum.php b/test/Mock/MockEnum.php index 623193e..a4407b6 100644 --- a/test/Mock/MockEnum.php +++ b/test/Mock/MockEnum.php @@ -8,7 +8,7 @@ class MockEnum { - const FOO = 1; - const BAR = 2; - const FOO_BAR = 3; + public const FOO = 1; + public const BAR = 2; + public const FOO_BAR = 3; } diff --git a/test/MockArray/MockArrayEnum.php b/test/MockArray/MockArrayEnum.php index c5b192b..c213180 100644 --- a/test/MockArray/MockArrayEnum.php +++ b/test/MockArray/MockArrayEnum.php @@ -8,7 +8,7 @@ class MockArrayEnum { - const FOO = 1; - const BAR = 2; - const FOO_ARRAY = [1, 2]; + public const FOO = 1; + public const BAR = 2; + public const FOO_ARRAY = [1, 2]; } diff --git a/test/MockNoArray/MockNoArray.php b/test/MockNoArray/MockNoArray.php index 810d35d..d397149 100644 --- a/test/MockNoArray/MockNoArray.php +++ b/test/MockNoArray/MockNoArray.php @@ -8,7 +8,7 @@ class MockNoArray { - const FOO = 1; - const BAR = 2; - const FOO_BAR = 3; + public const FOO = 1; + public const BAR = 2; + public const FOO_BAR = 3; } diff --git a/test/MockNoTrans/MockNoTransEnum.php b/test/MockNoTrans/MockNoTransEnum.php index 1b24a18..db70a0a 100644 --- a/test/MockNoTrans/MockNoTransEnum.php +++ b/test/MockNoTrans/MockNoTransEnum.php @@ -8,7 +8,7 @@ class MockNoTransEnum { - const FOO = 1; - const BAR = 2; - const FOO_BAR = 3; + public const FOO = 1; + public const BAR = 2; + public const FOO_BAR = 3; } diff --git a/test/MockXml/MockXmlEnum.php b/test/MockXml/MockXmlEnum.php index 5dede3b..2adb240 100644 --- a/test/MockXml/MockXmlEnum.php +++ b/test/MockXml/MockXmlEnum.php @@ -8,7 +8,7 @@ class MockXmlEnum { - const FOO = 1; - const BAR = 2; - const FOO_BAR = 3; + public const FOO = 1; + public const BAR = 2; + public const FOO_BAR = 3; }