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 diff --git a/composer.json b/composer.json index 552f291..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" }, @@ -32,5 +32,11 @@ "classmap": [ "test/Functional/Fixtures/TestKernel.php" ] + }, + "config": { + "allow-plugins": { + "hostnet/*": true, + "dealerdirect/phpcodesniffer-composer-installer": false + } } } 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; }