From 9e7b5f124847bc1e6b90c441b80122b85e5d4ab3 Mon Sep 17 00:00:00 2001 From: Holger Veltrup Date: Tue, 2 Jul 2024 11:45:31 +0200 Subject: [PATCH] feat: switch to php-cs-fixer --- .phive/phars.xml | 1 + .php-cs-fixer.dist.php | 12 ++ composer.json | 8 +- composer.lock | 192 +++++++++--------- phpcs.xml.dist | 25 --- src/AtooloRuntimeCheckBundle.php | 4 +- src/Console/Command/CheckCommand.php | 30 +-- src/Console/Command/Io/TypifiedInput.php | 8 +- src/Controller/CheckController.php | 7 +- src/Service/CheckStatus.php | 18 +- src/Service/Checker/CheckerCollection.php | 5 +- src/Service/Checker/MonologChecker.php | 27 ++- src/Service/Checker/PhpStatus.php | 26 +-- src/Service/Checker/ProcessStatus.php | 5 +- src/Service/Cli/FastCgiStatus.php | 21 +- src/Service/Cli/FastCgiStatusFactory.php | 16 +- src/Service/Cli/RuntimeCheck.php | 11 +- src/Service/FpmFcgi/CliStatus.php | 13 +- src/Service/FpmFcgi/RuntimeCheck.php | 13 +- src/Service/Platform.php | 4 +- src/Service/RuntimeStatus.php | 2 +- src/Service/Worker/WorkerCheckEvent.php | 4 +- src/Service/Worker/WorkerCheckScheduler.php | 11 +- src/Service/Worker/WorkerStatusFile.php | 19 +- test/Console/Command/CheckCommandTest.php | 16 +- test/Console/Command/Io/TypifiedInputTest.php | 12 +- test/Controller/CheckControllerTest.php | 28 +-- test/Service/CheckStatusTest.php | 36 ++-- .../Service/Checker/CheckerCollectionTest.php | 8 +- test/Service/Checker/MonologCheckerTest.php | 84 ++++---- test/Service/Checker/PhpStatusTest.php | 40 ++-- test/Service/Checker/ProcessStatusTest.php | 4 +- test/Service/Cli/FastCGIStatusTest.php | 28 +-- test/Service/Cli/FastCgiStatusFactoryTest.php | 20 +- test/Service/Cli/RuntimeCheckTest.php | 8 +- test/Service/FpmFcgi/CliStatusTest.php | 6 +- test/Service/FpmFcgi/RuntimeCheckTest.php | 8 +- test/Service/RuntimeStatusTest.php | 28 +-- test/Service/RuntimeTypeTest.php | 2 +- test/Service/Worker/OneTimeTriggerTest.php | 8 +- .../Worker/WorkerCheckSchedulerTest.php | 6 +- test/Service/Worker/WorkerStatusFileTest.php | 56 ++--- 42 files changed, 425 insertions(+), 455 deletions(-) create mode 100644 .php-cs-fixer.dist.php delete mode 100644 phpcs.xml.dist diff --git a/.phive/phars.xml b/.phive/phars.xml index 8bad0db..7a060a0 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -4,4 +4,5 @@ + diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..29895a6 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,12 @@ +in(__DIR__ . '/src') + ->in(__DIR__ . '/test'); + +return (new \PhpCsFixer\Config()) + ->setCacheFile('var/cache/php-cs-fixer') + ->setFinder($finder) + ->setRules(['@PER-CS' => true]); diff --git a/composer.json b/composer.json index f09e957..50d00d7 100644 --- a/composer.json +++ b/composer.json @@ -74,15 +74,15 @@ } }, "scripts": { - "post-install-cmd": "phive --no-progress install --force-accept-unsigned --trust-gpg-keys C00543248C87FB13,4AA394086372C20A,CF1A108D0E7AE720,51C67305FFC2E5C0", + "post-install-cmd": "phive --no-progress install --force-accept-unsigned --trust-gpg-keys C00543248C87FB13,4AA394086372C20A,CF1A108D0E7AE720,51C67305FFC2E5C0,E82B2FB314E9906E", "analyse": [ "@analyse:phplint", "@analyse:phpstan", - "@analyse:phpcs", + "@analyse:phpcsfixer", "@analyse:compatibilitycheck" ], "analyse:compatibilitycheck": "./vendor/bin/phpcs --standard=./phpcs.compatibilitycheck.xml", - "analyse:phpcs": "./vendor/bin/phpcs", + "analyse:phpcsfixer": "./tools/php-cs-fixer check --diff --show-progress=dots", "analyse:phplint": "./tools/phplint", "analyse:phpstan": "./tools/phpstan analyse", "cs-fix": [ @@ -90,10 +90,8 @@ ], "cs-fix:phpcbf": "./vendor/bin/phpcbf", "report": [ - "@report:phpcs", "@report:phpstan" ], - "report:phpcs": "./vendor/bin/phpcs || exit 0", "report:phpstan": "./tools/phpstan analyse --no-progress --no-ansi --no-interaction --error-format=checkstyle > ./var/log/phpstan-report.xml || exit 0", "test": [ "@test:phpunit" diff --git a/composer.lock b/composer.lock index 8983b2c..3013cb6 100644 --- a/composer.lock +++ b/composer.lock @@ -58,16 +58,16 @@ }, { "name": "monolog/monolog", - "version": "3.6.0", + "version": "3.7.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654" + "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", - "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f4393b648b78a5408747de94fca38beb5f7e9ef8", + "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8", "shasum": "" }, "require": { @@ -143,7 +143,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.6.0" + "source": "https://github.com/Seldaek/monolog/tree/3.7.0" }, "funding": [ { @@ -155,7 +155,7 @@ "type": "tidelift" } ], - "time": "2024-04-12T21:02:21+00:00" + "time": "2024-06-28T09:40:51+00:00" }, { "name": "psr/cache", @@ -409,16 +409,16 @@ }, { "name": "symfony/cache", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "760294dc7158372699dccd077965c16c328f8719" + "reference": "e933e1d947ffb88efcdd34a2bd51561cab7deaae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/760294dc7158372699dccd077965c16c328f8719", - "reference": "760294dc7158372699dccd077965c16c328f8719", + "url": "https://api.github.com/repos/symfony/cache/zipball/e933e1d947ffb88efcdd34a2bd51561cab7deaae", + "reference": "e933e1d947ffb88efcdd34a2bd51561cab7deaae", "shasum": "" }, "require": { @@ -486,7 +486,7 @@ "psr6" ], "support": { - "source": "https://github.com/symfony/cache/tree/v7.1.1" + "source": "https://github.com/symfony/cache/tree/v7.1.2" }, "funding": [ { @@ -502,7 +502,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-11T13:32:38+00:00" }, { "name": "symfony/cache-contracts", @@ -731,16 +731,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "77c636dfd86c0b60c5d184b2fd2ddf8dd11c309c" + "reference": "6e108cded928bdafaf1da3fabe30dd5af20e36b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/77c636dfd86c0b60c5d184b2fd2ddf8dd11c309c", - "reference": "77c636dfd86c0b60c5d184b2fd2ddf8dd11c309c", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6e108cded928bdafaf1da3fabe30dd5af20e36b9", + "reference": "6e108cded928bdafaf1da3fabe30dd5af20e36b9", "shasum": "" }, "require": { @@ -791,7 +791,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v7.1.1" + "source": "https://github.com/symfony/dependency-injection/tree/v7.1.2" }, "funding": [ { @@ -807,7 +807,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T10:03:55+00:00" }, { "name": "symfony/deprecation-contracts", @@ -878,16 +878,16 @@ }, { "name": "symfony/error-handler", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "e9b8bbce0b4f322939332ab7b6b81d8c11da27dd" + "reference": "2412d3dddb5c9ea51a39cfbff1c565fc9844ca32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/e9b8bbce0b4f322939332ab7b6b81d8c11da27dd", - "reference": "e9b8bbce0b4f322939332ab7b6b81d8c11da27dd", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/2412d3dddb5c9ea51a39cfbff1c565fc9844ca32", + "reference": "2412d3dddb5c9ea51a39cfbff1c565fc9844ca32", "shasum": "" }, "require": { @@ -933,7 +933,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v7.1.1" + "source": "https://github.com/symfony/error-handler/tree/v7.1.2" }, "funding": [ { @@ -949,7 +949,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-25T19:55:06+00:00" }, { "name": "symfony/event-dispatcher", @@ -1173,16 +1173,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "802e87002f919296c9f606457d9fa327a0b3d6b2" + "reference": "92a91985250c251de9b947a14bb2c9390b1a562c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/802e87002f919296c9f606457d9fa327a0b3d6b2", - "reference": "802e87002f919296c9f606457d9fa327a0b3d6b2", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/92a91985250c251de9b947a14bb2c9390b1a562c", + "reference": "92a91985250c251de9b947a14bb2c9390b1a562c", "shasum": "" }, "require": { @@ -1219,7 +1219,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.1" + "source": "https://github.com/symfony/filesystem/tree/v7.1.2" }, "funding": [ { @@ -1235,7 +1235,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T10:03:55+00:00" }, { "name": "symfony/finder", @@ -1303,16 +1303,16 @@ }, { "name": "symfony/framework-bundle", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/framework-bundle.git", - "reference": "79a20497022b8853416e20c836ee150b754c332a" + "reference": "54a84f49658e2e87167396b2259a55e55e11f4a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/79a20497022b8853416e20c836ee150b754c332a", - "reference": "79a20497022b8853416e20c836ee150b754c332a", + "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/54a84f49658e2e87167396b2259a55e55e11f4a2", + "reference": "54a84f49658e2e87167396b2259a55e55e11f4a2", "shasum": "" }, "require": { @@ -1430,7 +1430,7 @@ "description": "Provides a tight integration between Symfony components and the Symfony full-stack framework", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/framework-bundle/tree/v7.1.1" + "source": "https://github.com/symfony/framework-bundle/tree/v7.1.2" }, "funding": [ { @@ -1446,7 +1446,7 @@ "type": "tidelift" } ], - "time": "2024-06-04T06:40:14+00:00" + "time": "2024-06-28T08:00:31+00:00" }, { "name": "symfony/http-foundation", @@ -1527,16 +1527,16 @@ }, { "name": "symfony/http-kernel", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "fa8d1c75b5f33b1302afccf81811f93976c6e26f" + "reference": "ae3fa717db4d41a55d14c2bd92399e37cf5bc0f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/fa8d1c75b5f33b1302afccf81811f93976c6e26f", - "reference": "fa8d1c75b5f33b1302afccf81811f93976c6e26f", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/ae3fa717db4d41a55d14c2bd92399e37cf5bc0f6", + "reference": "ae3fa717db4d41a55d14c2bd92399e37cf5bc0f6", "shasum": "" }, "require": { @@ -1621,7 +1621,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.1.1" + "source": "https://github.com/symfony/http-kernel/tree/v7.1.2" }, "funding": [ { @@ -1637,7 +1637,7 @@ "type": "tidelift" } ], - "time": "2024-06-04T06:52:15+00:00" + "time": "2024-06-28T13:13:31+00:00" }, { "name": "symfony/lock", @@ -1719,16 +1719,16 @@ }, { "name": "symfony/messenger", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/messenger.git", - "reference": "70df0484323979f555df70bbb14d85c75f186010" + "reference": "8cafca5f0fade46acf4a6b32b2d5e495f798a56b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/messenger/zipball/70df0484323979f555df70bbb14d85c75f186010", - "reference": "70df0484323979f555df70bbb14d85c75f186010", + "url": "https://api.github.com/repos/symfony/messenger/zipball/8cafca5f0fade46acf4a6b32b2d5e495f798a56b", + "reference": "8cafca5f0fade46acf4a6b32b2d5e495f798a56b", "shasum": "" }, "require": { @@ -1785,7 +1785,7 @@ "description": "Helps applications send and receive messages to/from other applications or via message queues", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/messenger/tree/v7.1.1" + "source": "https://github.com/symfony/messenger/tree/v7.1.2" }, "funding": [ { @@ -1801,7 +1801,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T08:00:31+00:00" }, { "name": "symfony/password-hasher", @@ -2408,16 +2408,16 @@ }, { "name": "symfony/property-info", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/property-info.git", - "reference": "0f80f818c6728f15de30a4f89866d68e4912ae84" + "reference": "d7b91e4aa07e822a9b935fc29a7254c12d502f16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-info/zipball/0f80f818c6728f15de30a4f89866d68e4912ae84", - "reference": "0f80f818c6728f15de30a4f89866d68e4912ae84", + "url": "https://api.github.com/repos/symfony/property-info/zipball/d7b91e4aa07e822a9b935fc29a7254c12d502f16", + "reference": "d7b91e4aa07e822a9b935fc29a7254c12d502f16", "shasum": "" }, "require": { @@ -2472,7 +2472,7 @@ "validator" ], "support": { - "source": "https://github.com/symfony/property-info/tree/v7.1.1" + "source": "https://github.com/symfony/property-info/tree/v7.1.2" }, "funding": [ { @@ -2488,7 +2488,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-26T07:21:35+00:00" }, { "name": "symfony/routing", @@ -2653,16 +2653,16 @@ }, { "name": "symfony/security-core", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/security-core.git", - "reference": "536399671a46b0e615d69583f067e30ad25ad038" + "reference": "d615960211a11913e70f8576e5c38cd05d90ec3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-core/zipball/536399671a46b0e615d69583f067e30ad25ad038", - "reference": "536399671a46b0e615d69583f067e30ad25ad038", + "url": "https://api.github.com/repos/symfony/security-core/zipball/d615960211a11913e70f8576e5c38cd05d90ec3f", + "reference": "d615960211a11913e70f8576e5c38cd05d90ec3f", "shasum": "" }, "require": { @@ -2719,7 +2719,7 @@ "description": "Symfony Security Component - Core Library", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/security-core/tree/v7.1.1" + "source": "https://github.com/symfony/security-core/tree/v7.1.2" }, "funding": [ { @@ -2735,20 +2735,20 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T08:00:31+00:00" }, { "name": "symfony/security-http", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/security-http.git", - "reference": "8fa539ad9fe3c45452b8cca8381c2414cef78559" + "reference": "e9dc3ef093dac3d4982fcd96002525aa7a1d6989" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-http/zipball/8fa539ad9fe3c45452b8cca8381c2414cef78559", - "reference": "8fa539ad9fe3c45452b8cca8381c2414cef78559", + "url": "https://api.github.com/repos/symfony/security-http/zipball/e9dc3ef093dac3d4982fcd96002525aa7a1d6989", + "reference": "e9dc3ef093dac3d4982fcd96002525aa7a1d6989", "shasum": "" }, "require": { @@ -2807,7 +2807,7 @@ "description": "Symfony Security Component - HTTP Integration", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/security-http/tree/v7.1.1" + "source": "https://github.com/symfony/security-http/tree/v7.1.2" }, "funding": [ { @@ -2823,7 +2823,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-25T19:55:06+00:00" }, { "name": "symfony/service-contracts", @@ -2910,16 +2910,16 @@ }, { "name": "symfony/string", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "60bc311c74e0af215101235aa6f471bcbc032df2" + "reference": "14221089ac66cf82e3cf3d1c1da65de305587ff8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/60bc311c74e0af215101235aa6f471bcbc032df2", - "reference": "60bc311c74e0af215101235aa6f471bcbc032df2", + "url": "https://api.github.com/repos/symfony/string/zipball/14221089ac66cf82e3cf3d1c1da65de305587ff8", + "reference": "14221089ac66cf82e3cf3d1c1da65de305587ff8", "shasum": "" }, "require": { @@ -2977,7 +2977,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.1" + "source": "https://github.com/symfony/string/tree/v7.1.2" }, "funding": [ { @@ -2993,7 +2993,7 @@ "type": "tidelift" } ], - "time": "2024-06-04T06:40:14+00:00" + "time": "2024-06-28T09:27:18+00:00" }, { "name": "symfony/type-info", @@ -3079,16 +3079,16 @@ }, { "name": "symfony/var-dumper", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "deb2c2b506ff6fdbb340e00b34e9901e1605f293" + "reference": "5857c57c6b4b86524c08cf4f4bc95327270a816d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/deb2c2b506ff6fdbb340e00b34e9901e1605f293", - "reference": "deb2c2b506ff6fdbb340e00b34e9901e1605f293", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/5857c57c6b4b86524c08cf4f4bc95327270a816d", + "reference": "5857c57c6b4b86524c08cf4f4bc95327270a816d", "shasum": "" }, "require": { @@ -3142,7 +3142,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.1.1" + "source": "https://github.com/symfony/var-dumper/tree/v7.1.2" }, "funding": [ { @@ -3158,20 +3158,20 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T08:00:31+00:00" }, { "name": "symfony/var-exporter", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "db82c2b73b88734557cfc30e3270d83fa651b712" + "reference": "b80a669a2264609f07f1667f891dbfca25eba44c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/db82c2b73b88734557cfc30e3270d83fa651b712", - "reference": "db82c2b73b88734557cfc30e3270d83fa651b712", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/b80a669a2264609f07f1667f891dbfca25eba44c", + "reference": "b80a669a2264609f07f1667f891dbfca25eba44c", "shasum": "" }, "require": { @@ -3218,7 +3218,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v7.1.1" + "source": "https://github.com/symfony/var-exporter/tree/v7.1.2" }, "funding": [ { @@ -3234,7 +3234,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T08:00:31+00:00" }, { "name": "symfony/yaml", @@ -4430,16 +4430,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.14", + "version": "10.1.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b" + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", - "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", "shasum": "" }, "require": { @@ -4496,7 +4496,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.14" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.15" }, "funding": [ { @@ -4504,7 +4504,7 @@ "type": "github" } ], - "time": "2024-03-12T15:33:41+00:00" + "time": "2024-06-29T08:25:15+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6782,16 +6782,16 @@ }, { "name": "symfony/console", - "version": "v7.1.1", + "version": "v7.1.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9b008f2d7b21c74ef4d0c3de6077a642bc55ece3" + "reference": "0aa29ca177f432ab68533432db0de059f39c92ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9b008f2d7b21c74ef4d0c3de6077a642bc55ece3", - "reference": "9b008f2d7b21c74ef4d0c3de6077a642bc55ece3", + "url": "https://api.github.com/repos/symfony/console/zipball/0aa29ca177f432ab68533432db0de059f39c92ae", + "reference": "0aa29ca177f432ab68533432db0de059f39c92ae", "shasum": "" }, "require": { @@ -6855,7 +6855,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.1" + "source": "https://github.com/symfony/console/tree/v7.1.2" }, "funding": [ { @@ -6871,7 +6871,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:57:53+00:00" + "time": "2024-06-28T10:03:55+00:00" }, { "name": "thecodingmachine/safe", diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index 1ae9151..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - src/ - test/ - - - - - - - - - - diff --git a/src/AtooloRuntimeCheckBundle.php b/src/AtooloRuntimeCheckBundle.php index b9c8d33..063a607 100644 --- a/src/AtooloRuntimeCheckBundle.php +++ b/src/AtooloRuntimeCheckBundle.php @@ -29,8 +29,8 @@ public function build(ContainerBuilder $container): void new LoaderResolver( [ new YamlFileLoader($container, new FileLocator($configDir)), - ] - ) + ], + ), ); $loader->load('services.yaml'); diff --git a/src/Console/Command/CheckCommand.php b/src/Console/Command/CheckCommand.php index df9f295..692fbf5 100644 --- a/src/Console/Command/CheckCommand.php +++ b/src/Console/Command/CheckCommand.php @@ -22,7 +22,7 @@ final class CheckCommand extends Command { public function __construct( - private readonly RuntimeCheck $runtimeCheck + private readonly RuntimeCheck $runtimeCheck, ) { parent::__construct(); } @@ -33,8 +33,8 @@ protected function configure(): void ', ', array_map( fn(RuntimeType $type) => $type->value, - RuntimeType::cases() - ) + RuntimeType::cases(), + ), ); $this ->setHelp('Command to performs a check of the runtime environment') @@ -45,28 +45,28 @@ protected function configure(): void 'Skip check for different runtime-types' . ' (' . $runtimeTypes . ')' . ' and scopes (e.g. php, logging, ...)', - [] + [], ) ->addOption( 'fpm-socket', null, InputOption::VALUE_REQUIRED, 'fpm FastCGI socket like 127.0.0.1:9000 or ' - . '/var/run/php/php8.3-fpm.sock' + . '/var/run/php/php8.3-fpm.sock', ) ->addOption( 'fail-on-error', null, InputOption::VALUE_OPTIONAL, 'returns the exit code 1 if an error occurs', - true + true, ) ->addOption( 'json', null, InputOption::VALUE_NEGATABLE, 'output result in json.', - false + false, ) ; } @@ -76,20 +76,20 @@ protected function configure(): void */ protected function execute( InputInterface $input, - OutputInterface $output + OutputInterface $output, ): int { $typedInput = new TypifiedInput($input); $runtimeStatus = $this->runtimeCheck->execute( $typedInput->getArrayOption('skip'), - $typedInput->getStringOption('fpm-socket') + $typedInput->getStringOption('fpm-socket'), ); $this->outputResults( $output, $runtimeStatus, - $typedInput->getBoolOption('json') + $typedInput->getBoolOption('json'), ); $failOnError = $typedInput->getBoolOption('fail-on-error'); @@ -104,7 +104,7 @@ protected function execute( private function outputResults( OutputInterface $output, RuntimeStatus $runtimeStatus, - bool $json + bool $json, ): void { if ($json) { $output->writeln( @@ -112,8 +112,8 @@ private function outputResults( $runtimeStatus->serialize(), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT - | JSON_UNESCAPED_SLASHES - ) + | JSON_UNESCAPED_SLASHES, + ), ); } else { foreach (RuntimeType::cases() as $type) { @@ -126,14 +126,14 @@ private function outputResults( $value, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT - | JSON_UNESCAPED_SLASHES + | JSON_UNESCAPED_SLASHES, ); $output->writeln( '' . $type->value . '/' . $scope - . '' + . '', ); $output->writeln($value); $output->writeln(''); diff --git a/src/Console/Command/Io/TypifiedInput.php b/src/Console/Command/Io/TypifiedInput.php index 1a3a804..8927717 100644 --- a/src/Console/Command/Io/TypifiedInput.php +++ b/src/Console/Command/Io/TypifiedInput.php @@ -13,9 +13,7 @@ */ class TypifiedInput { - public function __construct(private readonly InputInterface $input) - { - } + public function __construct(private readonly InputInterface $input) {} public function getStringOption(string $name): ?string { @@ -25,7 +23,7 @@ public function getStringOption(string $name): ?string } if (!is_string($value)) { throw new InvalidArgumentException( - 'option ' . $name . ' must be a string: ' . $value + 'option ' . $name . ' must be a string: ' . $value, ); } return $value; @@ -42,7 +40,7 @@ public function getArrayOption(string $name): array } if (!is_array($value)) { throw new InvalidArgumentException( - 'option ' . $name . ' must be a array: ' . $value + 'option ' . $name . ' must be a array: ' . $value, ); } return $value; diff --git a/src/Controller/CheckController.php b/src/Controller/CheckController.php index 9772fe5..e1dacab 100644 --- a/src/Controller/CheckController.php +++ b/src/Controller/CheckController.php @@ -18,8 +18,7 @@ final class CheckController extends AbstractController { public function __construct( private readonly RuntimeCheck $runtimeCheck, - ) { - } + ) {} /** * @throws JsonException @@ -28,9 +27,9 @@ public function __construct( #[IsGranted( attribute: new Expression( 'is_granted("ROLE_SYSTEM_AUDITOR") ' - . 'or "127.0.0.1" == subject.getClientIp()' + . 'or "127.0.0.1" == subject.getClientIp()', ), - subject: new Expression('request') + subject: new Expression('request'), )] public function check(Request $request): Response { diff --git a/src/Service/CheckStatus.php b/src/Service/CheckStatus.php index 6f30a34..6c9faf6 100644 --- a/src/Service/CheckStatus.php +++ b/src/Service/CheckStatus.php @@ -19,9 +19,7 @@ class CheckStatus */ private array $reports = []; - public function __construct(public bool $success) - { - } + public function __construct(public bool $success) {} public static function createSuccess(): self { @@ -45,7 +43,7 @@ public function addMessages(string $scope, array $messages): self { $this->messages[$scope] = array_merge( $this->messages[$scope] ?? [], - $messages + $messages, ); return $this; } @@ -100,7 +98,7 @@ public function apply(CheckStatus $status): self $this->success = $this->success && $status->success; $this->messages = array_merge_recursive( $this->messages, - $status->messages + $status->messages, ); foreach ($status->reports as $scope => $result) { $this->addReport($scope, $result); @@ -115,7 +113,7 @@ public function serialize(): array { $data = [ 'success' => $this->success, - 'reports' => $this->reports + 'reports' => $this->reports, ]; if (!empty($this->messages)) { $data['messages'] = $this->messages; @@ -136,10 +134,10 @@ public static function deserialize(array $data): CheckStatus 'deserialize' => [ json_encode( $data, - JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES - ) - ] - ] + JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES, + ), + ], + ], ]; } $success = is_bool($data['success']) && $data['success']; diff --git a/src/Service/Checker/CheckerCollection.php b/src/Service/Checker/CheckerCollection.php index 711ea51..4233fd8 100644 --- a/src/Service/Checker/CheckerCollection.php +++ b/src/Service/Checker/CheckerCollection.php @@ -12,9 +12,8 @@ class CheckerCollection * @param iterable $checkers */ public function __construct( - private readonly iterable $checkers - ) { - } + private readonly iterable $checkers, + ) {} /** * @param array $scopesToSkip diff --git a/src/Service/Checker/MonologChecker.php b/src/Service/Checker/MonologChecker.php index a4d2976..afd3d90 100644 --- a/src/Service/Checker/MonologChecker.php +++ b/src/Service/Checker/MonologChecker.php @@ -28,9 +28,8 @@ public function __construct( private readonly string $maxLogFileSize, private readonly string $maxLogDirSize, private readonly int $maxLogFileRotations, - private readonly LoggerInterface $logger - ) { - } + private readonly LoggerInterface $logger, + ) {} public function getScope(): string { @@ -43,7 +42,7 @@ public function check(): CheckStatus $status = CheckStatus::createFailure(); $status->addMessage( $this->getScope(), - 'unknown: unsupported logger ' . get_class($this->logger) + 'unknown: unsupported logger ' . get_class($this->logger), ); return $status; } @@ -53,7 +52,7 @@ public function check(): CheckStatus $status = CheckStatus::createFailure(); $status->addMessage( $this->getScope(), - 'unknown: no stream handler found' + 'unknown: no stream handler found', ); return $status; } @@ -67,7 +66,7 @@ public function check(): CheckStatus private function checkHandler( CheckStatus $mergedStatus, - StreamHandler $handler + StreamHandler $handler, ): CheckStatus { $reportData = $this->getReportData($handler); @@ -85,13 +84,13 @@ private function checkHandler( return $this->createFailure( $mergedStatus, $reportData, - $errors + $errors, ); } return $this->createSuccess( $mergedStatus, - $reportData + $reportData, ); } @@ -116,7 +115,7 @@ private function getReportData(StreamHandler $handler): array $reportData['logfile-size'] = $fileSize; $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($dir) + new RecursiveDirectoryIterator($dir), ); $dirSize = 0; @@ -147,7 +146,7 @@ private function checkLogfile(?string $file): ?string $dir = dirname($file); if (!is_dir($dir)) { if (!@mkdir($dir, 0777, true) && !is_dir($dir)) { - return 'log directory cannot be created: ' . $dir; + return 'log directory cannot be created: ' . $dir; } } @@ -207,7 +206,7 @@ private function checkLogRotating(array $reportData): array private function createFailure( CheckStatus $mergedStatus, array $reportData, - array $messages + array $messages, ): CheckStatus { $status = $mergedStatus->apply(CheckStatus::createFailure()); $status->addMessages($this->getScope(), $messages); @@ -230,7 +229,7 @@ private function createSuccess( */ private function applyStatusReport( CheckStatus $status, - array $reportData + array $reportData, ): CheckStatus { /** * @var array{ @@ -248,7 +247,7 @@ private function applyStatusReport( * @return array */ private function getStreamHandlers( - Logger $logger + Logger $logger, ): array { $handlers = []; foreach ($logger->getHandlers() as $handler) { @@ -266,7 +265,7 @@ private function memoryStringToInteger(string $memory): int { [$number, $suffix] = sscanf($memory, '%u%c') ?? [null, null]; if (!is_string($suffix)) { - return (int)$memory; + return (int) $memory; } $pos = stripos(' KMG', $suffix); diff --git a/src/Service/Checker/PhpStatus.php b/src/Service/Checker/PhpStatus.php index ce2a424..afb7bc3 100644 --- a/src/Service/Checker/PhpStatus.php +++ b/src/Service/Checker/PhpStatus.php @@ -31,12 +31,12 @@ class PhpStatus public function __construct( string $config = __DIR__ . '/phpStatus.json', private readonly string $sapi = PHP_SAPI, - private readonly Platform $platform = new Platform() + private readonly Platform $platform = new Platform(), ) { $configContent = @file_get_contents($config); if ($configContent === false) { throw new RuntimeException( - 'Unable to read config file: ' . $config + 'Unable to read config file: ' . $config, ); } /** @var Config $data */ @@ -44,7 +44,7 @@ public function __construct( $configContent, true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $this->config = $data; } @@ -58,20 +58,20 @@ public function check(): CheckStatus { $report = [ 'version' => $this->platform->getVersion(), - 'ini' => $this->getIniSettings($this->config['ini'] ?? []) + 'ini' => $this->getIniSettings($this->config['ini'] ?? []), ]; if ($this->sapi === 'fpm-fcgi') { $fpm = []; $fpm['config'] = $this->getFpmConfig( - $this->config['fpm']['configDirs'] ?? [] + $this->config['fpm']['configDirs'] ?? [], ); $fpm['status'] = $this->getFpmPoolStatus( - $this->config['fpm']['status'] ?? [] + $this->config['fpm']['status'] ?? [], ); $report['fpm'] = $fpm; $report['opcache'] = $this->getOpcacheStatus( - $this->config['opcache'] ?? [] + $this->config['opcache'] ?? [], ); } @@ -87,7 +87,7 @@ public function check(): CheckStatus private function getIniSettings(array $names): array { $result = [ - 'file' => $this->platform->getPhpIniLoadedFile() + 'file' => $this->platform->getPhpIniLoadedFile(), ]; foreach ($names as $name) { $result[$name] = $this->platform->getIni($name); @@ -124,7 +124,7 @@ private function getFpmConfig(array $configDirs): array $globalConfig = @parse_ini_file($fpmConfigFile, true); if ($globalConfig === false) { throw new RuntimeException( - 'Unable to parse FPM config file: ' . $fpmConfigFile + 'Unable to parse FPM config file: ' . $fpmConfigFile, ); } @@ -139,7 +139,7 @@ private function getFpmConfig(array $configDirs): array $config = @parse_ini_file($file, true); if ($config === false) { throw new RuntimeException( - 'Unable to parse FPM config file: ' . $file + 'Unable to parse FPM config file: ' . $file, ); } $configs[] = $config; @@ -160,14 +160,14 @@ private function getFpmConfigFile(array $configDirs): ?string [ '{PHP_VERSION_MAJOR}', '{PHP_VERSION_MINOR}', - '{PHP_VERSION_PATCH}' + '{PHP_VERSION_PATCH}', ], [ $version[0], $version[1], - $version[2] + $version[2], ], - $configDir + $configDir, ); $iniFilePath = $configDir . '/php-fpm.conf'; if (file_exists($iniFilePath)) { diff --git a/src/Service/Checker/ProcessStatus.php b/src/Service/Checker/ProcessStatus.php index 6a5bfa2..de424a5 100644 --- a/src/Service/Checker/ProcessStatus.php +++ b/src/Service/Checker/ProcessStatus.php @@ -13,9 +13,8 @@ class ProcessStatus implements Checker * @throws \JsonException */ public function __construct( - private readonly Platform $platform = new Platform() - ) { - } + private readonly Platform $platform = new Platform(), + ) {} public function getScope(): string diff --git a/src/Service/Cli/FastCgiStatus.php b/src/Service/Cli/FastCgiStatus.php index dad25fa..26d2303 100644 --- a/src/Service/Cli/FastCgiStatus.php +++ b/src/Service/Cli/FastCgiStatus.php @@ -24,9 +24,8 @@ public function __construct( private readonly ConfiguresSocketConnection $connection, private readonly string $frontControllerPath, private readonly string $resourceRoot, - private readonly string $resourceHost - ) { - } + private readonly string $resourceHost, + ) {} /** * @internal For testing purposes only @@ -63,13 +62,13 @@ public function request(array $skip): CheckStatus $request->setCustomVar('RESOURCE_ROOT', $this->resourceRoot); $request->setCustomVar( 'DOCUMENT_ROOT', - dirname($this->frontControllerPath) + dirname($this->frontControllerPath), ); try { $res = $this->client->sendRequest( $this->connection, - $request + $request, ); $body = $res->getBody(); @@ -79,7 +78,7 @@ public function request(array $skip): CheckStatus $body, true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); } catch (JsonException $e) { return CheckStatus::createFailure() @@ -88,8 +87,8 @@ public function request(array $skip): CheckStatus sprintf( "JSON error: %s\n%s", $e->getMessage(), - $body - ) + $body, + ), ); } @@ -98,7 +97,7 @@ public function request(array $skip): CheckStatus return $status ?? CheckStatus::createFailure() ->addMessage( 'fpm-fcgi', - 'No FastCGI status found in response.' + 'No FastCGI status found in response.', ); } catch (Throwable $e) { return CheckStatus::createFailure() @@ -107,8 +106,8 @@ public function request(array $skip): CheckStatus sprintf( 'FastCGI error: %s (%s)', $e->getMessage(), - $this->socket - ) + $this->socket, + ), ); } } diff --git a/src/Service/Cli/FastCgiStatusFactory.php b/src/Service/Cli/FastCgiStatusFactory.php index 3ff8294..8eed9f5 100644 --- a/src/Service/Cli/FastCgiStatusFactory.php +++ b/src/Service/Cli/FastCgiStatusFactory.php @@ -23,7 +23,7 @@ public function __construct( private readonly array $possibleSocketFilePatterns, private readonly string $frontControllerPath, ?string $resourceRoot, - ?string $resourceHost + ?string $resourceHost, ) { if (empty($resourceRoot)) { throw new RuntimeException( @@ -31,12 +31,12 @@ public function __construct( The resource-root could not be determined. This is the case if the console command was not called via the resource-root path - EOF + EOF, ); } if (empty($resourceHost)) { throw new RuntimeException( - 'resource host not set' + 'resource host not set', ); } @@ -55,7 +55,7 @@ public function create(?string $socket = null): FastCgiStatus $connection, $this->frontControllerPath, $this->resourceRoot, - $this->resourceHost + $this->resourceHost, ); } @@ -77,7 +77,7 @@ private function determineSocket(): string } private function createConnection( - string $socket + string $socket, ): ConfiguresSocketConnection { $last = strrpos($socket, ':'); if ($last !== false) { @@ -86,16 +86,16 @@ private function createConnection( return new NetworkSocket( $host, - (int)$port, + (int) $port, 5000, # Connect timeout in milliseconds (default: 5000) - 120000 # Read/write timeout in milliseconds (default: 5000) + 120000, # Read/write timeout in milliseconds (default: 5000) ); } return new UnixDomainSocket( $socket, 5000, # Connect timeout in milliseconds (default: 5000) - 120000 # Read/write timeout in milliseconds (default: 5000) + 120000, # Read/write timeout in milliseconds (default: 5000) ); } } diff --git a/src/Service/Cli/RuntimeCheck.php b/src/Service/Cli/RuntimeCheck.php index 9eb1ed9..03135a1 100644 --- a/src/Service/Cli/RuntimeCheck.php +++ b/src/Service/Cli/RuntimeCheck.php @@ -16,8 +16,7 @@ public function __construct( private readonly CheckerCollection $checkerCollection, private readonly FastCgiStatusFactory $fastCgiStatusFactory, private readonly WorkerStatusFile $workerStatusFile, - ) { - } + ) {} /** * @param array $skip @@ -28,19 +27,19 @@ public function execute(array $skip, ?string $fpmSocket): RuntimeStatus if (!in_array(RuntimeType::CLI->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::CLI, - $this->getCliStatus($skip) + $this->getCliStatus($skip), ); } if (!in_array(RuntimeType::FPM_FCGI->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::FPM_FCGI, - $this->getFpmFcgiStatus($skip, $fpmSocket) + $this->getFpmFcgiStatus($skip, $fpmSocket), ); } if (!in_array(RuntimeType::WORKER->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::WORKER, - $this->getWorkerStatus($skip) + $this->getWorkerStatus($skip), ); } @@ -60,7 +59,7 @@ private function getCliStatus(array $skip): CheckStatus */ private function getFpmFcgiStatus( array $skip, - ?string $fpmSocket + ?string $fpmSocket, ): CheckStatus { $fastCgi = $this->fastCgiStatusFactory->create($fpmSocket); return $fastCgi->request($skip); diff --git a/src/Service/FpmFcgi/CliStatus.php b/src/Service/FpmFcgi/CliStatus.php index ab2c47f..3d84c1f 100644 --- a/src/Service/FpmFcgi/CliStatus.php +++ b/src/Service/FpmFcgi/CliStatus.php @@ -15,9 +15,8 @@ class CliStatus { public function __construct( private readonly string $consoleBinPath, - private readonly string $resourceRoot - ) { - } + private readonly string $resourceRoot, + ) {} /** * @param array $skip @@ -34,13 +33,13 @@ public function execute(array $skip): CheckStatus 'runtime:check', '--fail-on-error', 'false', '--skip', implode(',', $skip), - '--json' + '--json', ]); $process->setEnv(['RESOURCE_ROOT' => $this->resourceRoot]); try { $process->run(); - // @codeCoverageIgnoreStart - // found no way to test this + // @codeCoverageIgnoreStart + // found no way to test this } catch (Exception $e) { return CheckStatus::createFailure() ->addMessage('cli', trim($e->getMessage())); @@ -57,7 +56,7 @@ public function execute(array $skip): CheckStatus $process->getOutput(), true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $status = RuntimeStatus::deserialize($data) ->getStatus(RuntimeType::CLI); diff --git a/src/Service/FpmFcgi/RuntimeCheck.php b/src/Service/FpmFcgi/RuntimeCheck.php index fc08d18..c70efd5 100644 --- a/src/Service/FpmFcgi/RuntimeCheck.php +++ b/src/Service/FpmFcgi/RuntimeCheck.php @@ -17,8 +17,7 @@ public function __construct( private readonly CheckerCollection $checkerCollection, private readonly CliStatus $cliStatus, private readonly WorkerStatusFile $workerStatusFile, - ) { - } + ) {} /** * @param array $skip @@ -30,19 +29,19 @@ public function execute(array $skip): RuntimeStatus if (!in_array(RuntimeType::FPM_FCGI->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::FPM_FCGI, - $this->getFpmFcgiStatus($skip) + $this->getFpmFcgiStatus($skip), ); } if (!in_array(RuntimeType::CLI->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::CLI, - $this->getCliStatus($skip) + $this->getCliStatus($skip), ); } if (!in_array(RuntimeType::WORKER->value, $skip, true)) { $runtimeStatus->addStatus( RuntimeType::WORKER, - $this->getWorkerStatus($skip) + $this->getWorkerStatus($skip), ); } @@ -53,11 +52,11 @@ public function execute(array $skip): RuntimeStatus * @param array $skip */ private function getFpmFcgiStatus( - array $skip + array $skip, ): CheckStatus { $status = $this->checkerCollection->check($skip); $status->addReport('server', [ - 'host' => $_SERVER['SERVER_NAME'] ?? 'unknown' + 'host' => $_SERVER['SERVER_NAME'] ?? 'unknown', ]); return $status; } diff --git a/src/Service/Platform.php b/src/Service/Platform.php index cf3e453..3b347e2 100644 --- a/src/Service/Platform.php +++ b/src/Service/Platform.php @@ -17,13 +17,13 @@ public function time(): int public function getUser(): string { return (posix_getpwuid(posix_geteuid()) - ?: ['name' => (string)posix_geteuid()])['name']; + ?: ['name' => (string) posix_geteuid()])['name']; } public function getGroup(): string { return (posix_getgrgid(posix_getegid()) - ?: ['name' => (string)posix_getegid()])['name']; + ?: ['name' => (string) posix_getegid()])['name']; } /** diff --git a/src/Service/RuntimeStatus.php b/src/Service/RuntimeStatus.php index 75cee03..30bf642 100644 --- a/src/Service/RuntimeStatus.php +++ b/src/Service/RuntimeStatus.php @@ -30,7 +30,7 @@ public function getTypes(): array function (string $type) { return RuntimeType::from($type); }, - array_keys($this->status) + array_keys($this->status), ); } diff --git a/src/Service/Worker/WorkerCheckEvent.php b/src/Service/Worker/WorkerCheckEvent.php index 0b098a9..d040a6f 100644 --- a/src/Service/Worker/WorkerCheckEvent.php +++ b/src/Service/Worker/WorkerCheckEvent.php @@ -7,6 +7,4 @@ /** * @codeCoverageIgnore */ -class WorkerCheckEvent -{ -} +class WorkerCheckEvent {} diff --git a/src/Service/Worker/WorkerCheckScheduler.php b/src/Service/Worker/WorkerCheckScheduler.php index 9084461..1a54e61 100644 --- a/src/Service/Worker/WorkerCheckScheduler.php +++ b/src/Service/Worker/WorkerCheckScheduler.php @@ -25,10 +25,9 @@ public function __construct( private readonly CheckerCollection $checkerCollection, private readonly string $host, private readonly LockFactory $lockFactory = new LockFactory( - new SemaphoreStore() + new SemaphoreStore(), ), - ) { - } + ) {} public function getSchedule(): Schedule { @@ -36,14 +35,14 @@ public function getSchedule(): Schedule ->add( RecurringMessage::trigger( new OneTimeTrigger(), - new WorkerCheckEvent() + new WorkerCheckEvent(), ), RecurringMessage::every( $this->workerStatusFile->updatePeriodInMinutes . ' minutes', - new WorkerCheckEvent() + new WorkerCheckEvent(), ), )->lock($this->lockFactory->createLock( - 'runtime-check-scheduler-' . $this->host + 'runtime-check-scheduler-' . $this->host, )); } diff --git a/src/Service/Worker/WorkerStatusFile.php b/src/Service/Worker/WorkerStatusFile.php index 40cc278..5589098 100644 --- a/src/Service/Worker/WorkerStatusFile.php +++ b/src/Service/Worker/WorkerStatusFile.php @@ -15,9 +15,8 @@ class WorkerStatusFile public function __construct( private readonly string $workerStatusFile, public readonly int $updatePeriodInMinutes, - private readonly Platform $platform = new Platform() - ) { - } + private readonly Platform $platform = new Platform(), + ) {} /** * @throws JsonException @@ -34,7 +33,7 @@ public function read(): CheckStatus $workerStatusFileContent = @file_get_contents($this->workerStatusFile); if ($workerStatusFileContent === false) { throw new RuntimeException( - 'Unable to read file ' . $this->workerStatusFile + 'Unable to read file ' . $this->workerStatusFile, ); } @@ -43,7 +42,7 @@ public function read(): CheckStatus $workerStatusFileContent, true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $allowedTime = @@ -62,7 +61,7 @@ public function read(): CheckStatus $checkStatus ->replaceReport( 'scheduler', - $result['reports']['scheduler'] + $result['reports']['scheduler'], ); } $checkStatus @@ -71,7 +70,7 @@ public function read(): CheckStatus 'The worker did not run in the last ' . $this->updatePeriodInMinutes . ' minutes. Last run: ' - . $formattedLastRun + . $formattedLastRun, ); } @@ -92,15 +91,15 @@ public function write(CheckStatus $status): void ]); } $status->addReport('scheduler', [ - 'last-run' => $now->format('d.m.Y H:i:s') + 'last-run' => $now->format('d.m.Y H:i:s'), ]); file_put_contents( $this->workerStatusFile, json_encode( $status->serialize(), - JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR - ) + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR, + ), ); } } diff --git a/test/Console/Command/CheckCommandTest.php b/test/Console/Command/CheckCommandTest.php index 6ad3a81..bb453d4 100644 --- a/test/Console/Command/CheckCommandTest.php +++ b/test/Console/Command/CheckCommandTest.php @@ -23,7 +23,7 @@ class CheckCommandTest extends TestCase public function setUp(): void { $this->runtimeCheck = $this->createStub( - RuntimeCheck::class + RuntimeCheck::class, ); $command = new CheckCommand( @@ -40,7 +40,7 @@ public function testExecuteSuccess(): void $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus(RuntimeType::CLI, $checkStatus); $this->runtimeCheck->method('execute')->willReturn( - $runtimeStatus + $runtimeStatus, ); $this->commandTester->execute([]); @@ -55,7 +55,7 @@ public function testExecuteSuccess(): void EOF, $this->commandTester->getDisplay(), - 'Command should display failure message' + 'Command should display failure message', ); } @@ -68,7 +68,7 @@ public function testExecuteFailure(): void $runtimeStatus->addStatus(RuntimeType::CLI, $status); $this->runtimeCheck->method('execute')->willReturn( - $runtimeStatus + $runtimeStatus, ); $this->commandTester->execute([]); @@ -79,7 +79,7 @@ public function testExecuteFailure(): void EOF, $this->commandTester->getDisplay(), - 'Command should display failure message' + 'Command should display failure message', ); } @@ -90,11 +90,11 @@ public function testJsonResult(): void $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus(RuntimeType::CLI, $checkStatus); $this->runtimeCheck->method('execute')->willReturn( - $runtimeStatus + $runtimeStatus, ); $this->commandTester->execute( - ['--json' => true] + ['--json' => true], ); $this->assertEquals( <<commandTester->getDisplay(), - 'Command should display json result' + 'Command should display json result', ); } } diff --git a/test/Console/Command/Io/TypifiedInputTest.php b/test/Console/Command/Io/TypifiedInputTest.php index 4fcce07..a0504b9 100644 --- a/test/Console/Command/Io/TypifiedInputTest.php +++ b/test/Console/Command/Io/TypifiedInputTest.php @@ -29,7 +29,7 @@ public function testGetStringOption(): void $this->assertEquals( 'abc', $input->getStringOption('a'), - 'unexpected option value' + 'unexpected option value', ); } @@ -47,7 +47,7 @@ public function testGetStringMissingOption(): void $this->assertNull( $input->getStringOption('a'), - 'unexpected option value' + 'unexpected option value', ); } @@ -82,7 +82,7 @@ public function testGetBoolOption(): void $this->assertEquals( true, $input->getBoolOption('a'), - 'unexpected option value' + 'unexpected option value', ); } @@ -101,7 +101,7 @@ public function testGetBoolOptWithInvalidValue(): void $this->assertEquals( false, $input->getBoolOption('a'), - 'unexpected option value' + 'unexpected option value', ); } @@ -120,7 +120,7 @@ public function testGetArrayOption(): void $this->assertEquals( ['abc'], $input->getArrayOption('a'), - 'unexpected option value' + 'unexpected option value', ); } @@ -139,7 +139,7 @@ public function testGetArrayOptionMissingValue(): void $this->assertEquals( [], $input->getArrayOption('a'), - 'unexpected option value' + 'unexpected option value', ); } diff --git a/test/Controller/CheckControllerTest.php b/test/Controller/CheckControllerTest.php index ca78608..278adf9 100644 --- a/test/Controller/CheckControllerTest.php +++ b/test/Controller/CheckControllerTest.php @@ -34,13 +34,13 @@ public function testCheck(): void { $checkStatus = CheckStatus::createSuccess(); $checkStatus->addReport('test', [ - 'a' => 'b' + 'a' => 'b', ]); $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus(RuntimeType::CLI, $checkStatus); $this->runtimeCheck->method('execute')->willReturn( - $runtimeStatus + $runtimeStatus, ); $request = $this->createMock(Request::class); @@ -49,7 +49,7 @@ public function testCheck(): void $response->getContent(), true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $this->assertEquals( [ @@ -57,14 +57,14 @@ public function testCheck(): void 'cli' => [ 'reports' => [ 'test' => [ - 'a' => 'b' - ] + 'a' => 'b', + ], ], - 'success' => true - ] + 'success' => true, + ], ], $json, - 'Unexpected response content' + 'Unexpected response content', ); } @@ -79,15 +79,15 @@ public function testCheckWithSkipArray(): void ->with( [ RuntimeType::CLI->value, - ] + ], ); $request = $this->createMock(Request::class); $request->method('get') ->with('skip') ->willReturn( [ - RuntimeType::CLI->value - ] + RuntimeType::CLI->value, + ], ); $this->controller->check($request); @@ -103,13 +103,13 @@ public function testCheckWithSkipString(): void ->method('execute') ->with([ RuntimeType::CLI->value, - RuntimeType::WORKER->value + RuntimeType::WORKER->value, ]); $request = $this->createMock(Request::class); $request->method('get') ->with('skip') ->willReturn( - RuntimeType::CLI->value . ',' . RuntimeType::WORKER->value + RuntimeType::CLI->value . ',' . RuntimeType::WORKER->value, ); $this->controller->check($request); @@ -128,7 +128,7 @@ public function testCheckWithUnsupportedSkipType(): void $request->method('get') ->with('skip') ->willReturn( - true + true, ); $this->controller->check($request); diff --git a/test/Service/CheckStatusTest.php b/test/Service/CheckStatusTest.php index 699d65f..5e64fa2 100644 --- a/test/Service/CheckStatusTest.php +++ b/test/Service/CheckStatusTest.php @@ -29,10 +29,10 @@ public function testAddMessage(): void $status->addMessage('scope', 'message'); self::assertSame( [ - 'scope' => ['message'] + 'scope' => ['message'], ], $status->getMessages(), - 'Message was not added correctly' + 'Message was not added correctly', ); } @@ -42,10 +42,10 @@ public function testAddReport(): void $status->addReport('scope', ['result']); self::assertSame( [ - 'scope' => ['result'] + 'scope' => ['result'], ], $status->getReports(), - 'Result was not added correctly' + 'Result was not added correctly', ); } @@ -56,10 +56,10 @@ public function testReplaceReport(): void $status->replaceReport('scope', ['result2']); self::assertSame( [ - 'scope' => ['result2'] + 'scope' => ['result2'], ], $status->getReports(), - 'Result was not replaced' + 'Result was not replaced', ); } @@ -70,7 +70,7 @@ public function testGetReport(): void self::assertSame( ['result'], $status->getReport('scope'), - 'unexpected result' + 'unexpected result', ); } @@ -80,7 +80,7 @@ public function testGetMissingReport(): void self::assertSame( [], $status->getReport('scope'), - 'unexpected result' + 'unexpected result', ); } @@ -105,7 +105,7 @@ public function testApply(): void self::assertEquals( $expected, $status, - 'Status was not applied correctly' + 'Status was not applied correctly', ); } @@ -120,15 +120,15 @@ public function testSerialize(): void 'success' => true, 'reports' => [ 'scope' => [ - 'a' => 'b' + 'a' => 'b', ], ], 'messages' => [ - 'scope' => ['message'] + 'scope' => ['message'], ], ], $serialized, - 'Status was not serialized correctly' + 'Status was not serialized correctly', ); } @@ -138,11 +138,11 @@ public function testDeserialize(): void 'success' => true, 'reports' => [ 'scope' => [ - 'a' => 'b' + 'a' => 'b', ], ], 'messages' => [ - 'scope' => ['message'] + 'scope' => ['message'], ], ]; $status = CheckStatus::deserialize($serialized); @@ -153,7 +153,7 @@ public function testDeserialize(): void self::assertEquals( $expected, $status, - 'Status was not deserialized correctly' + 'Status was not deserialized correctly', ); } @@ -164,20 +164,20 @@ public function testWithUnknownJson(): void { $serialized = [ 'code' => 401, - 'message' => "JWT Token not found" + 'message' => "JWT Token not found", ]; $status = CheckStatus::deserialize($serialized); $expected = new CheckStatus(false); $expected->addMessage( 'deserialize', - json_encode($serialized, JSON_THROW_ON_ERROR) + json_encode($serialized, JSON_THROW_ON_ERROR), ); self::assertEquals( $expected, $status, - 'Status was not deserialized correctly' + 'Status was not deserialized correctly', ); } } diff --git a/test/Service/Checker/CheckerCollectionTest.php b/test/Service/Checker/CheckerCollectionTest.php index dc98218..6c83e55 100644 --- a/test/Service/Checker/CheckerCollectionTest.php +++ b/test/Service/Checker/CheckerCollectionTest.php @@ -17,7 +17,7 @@ public function testCheck(): void { $checkerA = $this->createStub(Checker::class); $checkerA->method('check')->willReturn( - CheckStatus::createSuccess()->addReport('a', ['a' => 'b']) + CheckStatus::createSuccess()->addReport('a', ['a' => 'b']), ); $checkerA->method('getScope')->willReturn('a'); @@ -30,7 +30,7 @@ public function testCheck(): void $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -38,7 +38,7 @@ public function testSkipCheck(): void { $checker = $this->createStub(Checker::class); $checker->method('check')->willReturn( - CheckStatus::createSuccess()->addReport('a', ['a' => 'b']) + CheckStatus::createSuccess()->addReport('a', ['a' => 'b']), ); $checker->method('getScope')->willReturn('a'); @@ -50,7 +50,7 @@ public function testSkipCheck(): void $this->assertEquals( $expected, $status, - 'checker should be skipped' + 'checker should be skipped', ); } } diff --git a/test/Service/Checker/MonologCheckerTest.php b/test/Service/Checker/MonologCheckerTest.php index 01a1aa8..512ea51 100644 --- a/test/Service/Checker/MonologCheckerTest.php +++ b/test/Service/Checker/MonologCheckerTest.php @@ -20,7 +20,7 @@ class MonologCheckerTest extends TestCase { private string $resourceDir = __DIR__ - . '/../../resources/Service/Checker/MonologCheckerTest'; + . '/../../resources/Service/Checker/MonologCheckerTest'; private string $testDir = __DIR__ . '/../../../var/test/MonologCheckerTest'; @@ -46,12 +46,12 @@ public function testCheckWithWrongLogger(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'logging', - 'unknown: unsupported logger ' . get_class($logger) + 'unknown: unsupported logger ' . get_class($logger), ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -67,12 +67,12 @@ public function testCheckWithoutStreamHandler(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'logging', - 'unknown: no stream handler found' + 'unknown: no stream handler found', ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -90,25 +90,25 @@ public function testCheckWithoutLogfile(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'logging', - 'logfile not set' + 'logfile not set', ); $expected = CheckStatus::createFailure(); $expected->addReport('logging', [ 'handler' => [ [ 'logfile' => null, - 'level' => 'WARNING' - ] - ] + 'level' => 'WARNING', + ], + ], ]); $expected->addMessage( 'logging', - 'logfile not set' + 'logfile not set', ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -135,23 +135,23 @@ public function testCheckLogfileNotWritable(): void $expected = CheckStatus::createFailure(); $expected->addReport('logging', [ 'handler' => [ - [ + [ 'logfile' => $file, 'level' => 'WARNING', 'logfile-size' => 0, 'logdir-size' => 0, - 'logfile-rotations' => 0 - ] - ] + 'logfile-rotations' => 0, + ], + ], ]); $expected->addMessage( 'logging', - 'logfile not writable: ' . $file + 'logfile not writable: ' . $file, ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } finally { $filesystem->chmod($file, 0666); @@ -181,18 +181,18 @@ public function testCheckDirNotCreateable(): void 'handler' => [ [ 'logfile' => $file, - 'level' => 'WARNING' - ] - ] + 'level' => 'WARNING', + ], + ], ]); $expected->addMessage( 'logging', - 'log directory cannot be created: ' . dirname($file) + 'log directory cannot be created: ' . dirname($file), ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } finally { $filesystem->chmod($dir, 0777); @@ -223,18 +223,18 @@ public function testCheckFileNotCreateable(): void 'handler' => [ [ 'logfile' => $file, - 'level' => 'WARNING' - ] - ] + 'level' => 'WARNING', + ], + ], ]); $expected->addMessage( 'logging', - 'logfile cannot be created: ' . $file + 'logfile cannot be created: ' . $file, ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } finally { $filesystem->chmod($dir, 0777); @@ -262,14 +262,14 @@ public function testCheckSuccessfully(): void 'level' => 'WARNING', 'logfile-size' => 18, 'logdir-size' => 70, - 'logfile-rotations' => 4 - ] - ] + 'logfile-rotations' => 4, + ], + ], ]); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -283,7 +283,7 @@ public function testWithFingersCrossedHandler(): void $handler->method('getLevel')->willReturn(Level::Warning); $fingersCrossedHandler = $this->createStub( - FingersCrossedHandler::class + FingersCrossedHandler::class, ); $fingersCrossedHandler->method('getHandler') ->willReturn($handler); @@ -302,14 +302,14 @@ public function testWithFingersCrossedHandler(): void 'level' => 'WARNING', 'logfile-size' => 18, 'logdir-size' => 70, - 'logfile-rotations' => 4 - ] - ] + 'logfile-rotations' => 4, + ], + ], ]); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } @@ -333,22 +333,22 @@ public function testCheckLogRotatingWithErrors(): void 'level' => 'WARNING', 'logfile-size' => 18, 'logdir-size' => 70, - 'logfile-rotations' => 4 - ] - ] + 'logfile-rotations' => 4, + ], + ], ]); $expected->addMessages( 'logging', [ 'logfile size exceeds 10 bytes', 'logdir size exceeds 20 bytes', - 'logfile rotations exceed 1' - ] + 'logfile rotations exceed 1', + ], ); $this->assertEquals( $expected, $status, - 'Status is not as expected' + 'Status is not as expected', ); } } diff --git a/test/Service/Checker/PhpStatusTest.php b/test/Service/Checker/PhpStatusTest.php index ad1c42d..d5b1286 100644 --- a/test/Service/Checker/PhpStatusTest.php +++ b/test/Service/Checker/PhpStatusTest.php @@ -32,19 +32,19 @@ public function setUp(): void ->willReturn('php.ini'); $this->platform->method('getIni') ->willReturnMap([ - ['date.timezone', 'Timezone'] + ['date.timezone', 'Timezone'], ]); $this->platform->method('getVersion') ->willReturn('8.3.0'); $this->platform->method('getOpcacheGetStatus') ->willReturn([ 'memory_usage' => '123', - 'other' => 'test' + 'other' => 'test', ]); $this->platform->method('getFpmPoolStatus') ->willReturn([ 'pool' => 'www', - 'other' => 'test' + 'other' => 'test', ]); } @@ -56,7 +56,7 @@ public function testGetStatus(): void $phpStatus = new PhpStatus( $this->resourceDir . '/phpStatus.json', 'fpm-fcgi', - $this->platform + $this->platform, ); $status = $phpStatus->check(); @@ -65,30 +65,30 @@ public function testGetStatus(): void 'version' => '8.3.0', 'ini' => [ 'file' => 'php.ini', - 'date.timezone' => 'Timezone' + 'date.timezone' => 'Timezone', ], 'fpm' => [ 'config' => [ 'section' => [ 'key' => 'value', - 'includetest' => 'test' + 'includetest' => 'test', ], 'global' => [ - 'include' => 'fpm/conf.d/*.conf' - ] + 'include' => 'fpm/conf.d/*.conf', + ], ], 'status' => [ - 'pool' => 'www' - ] + 'pool' => 'www', + ], ], 'opcache' => [ - 'memory_usage' => '123' - ] + 'memory_usage' => '123', + ], ]); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } @@ -98,7 +98,7 @@ public function testGetStatusUnreadablePhpFpmConf(): void $phpStatus = new PhpStatus( $this->resourceDir . '/phpStatus-unreadable-php-fpm-conf.json', 'fpm-fcgi', - $this->platform + $this->platform, ); $phpStatus->check(); } @@ -113,7 +113,7 @@ public function testGetStatusUnreadablePhpFpmConfInclude(): void $this->resourceDir . '/phpStatus-unreadable-php-fpm-conf-include.json', 'fpm-fcgi', - $this->platform + $this->platform, ); $phpStatus->check(); } @@ -123,7 +123,7 @@ public function testGetStatusWithEmptyConfig(): void $phpStatus = new PhpStatus( $this->resourceDir . '/empty-phpStatus.json', 'fpm-fcgi', - $this->platform + $this->platform, ); $status = $phpStatus->check(); $expected = CheckStatus::createSuccess(); @@ -136,16 +136,16 @@ public function testGetStatusWithEmptyConfig(): void 'config' => [ ], 'status' => [ - ] + ], ], 'opcache' => [ - ] + ], ]); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } @@ -158,7 +158,7 @@ public function testGetStatusWithUnreadableConfig(): void new PhpStatus( $this->resourceDir . '/non-exists-phpStatus.json', 'fpm-fcgi', - $this->platform + $this->platform, ); } } diff --git a/test/Service/Checker/ProcessStatusTest.php b/test/Service/Checker/ProcessStatusTest.php index 947b635..8ff6176 100644 --- a/test/Service/Checker/ProcessStatusTest.php +++ b/test/Service/Checker/ProcessStatusTest.php @@ -36,7 +36,7 @@ public function setUp(): void public function testGetStatus(): void { $processStatus = new ProcessStatus( - $this->platform + $this->platform, ); $status = $processStatus->check(); @@ -49,7 +49,7 @@ public function testGetStatus(): void $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } } diff --git a/test/Service/Cli/FastCGIStatusTest.php b/test/Service/Cli/FastCGIStatusTest.php index 7e91fdd..1deca63 100644 --- a/test/Service/Cli/FastCGIStatusTest.php +++ b/test/Service/Cli/FastCGIStatusTest.php @@ -26,7 +26,7 @@ public function setUp(): void { $this->client = $this->createMock(Client::class); $this->connection = $this->createMock( - ConfiguresSocketConnection::class + ConfiguresSocketConnection::class, ); $this->response = $this->createStub(ProvidesResponseData::class); @@ -36,7 +36,7 @@ public function setUp(): void $this->connection, '/path/to/front-controller', '', - '' + '', ); } @@ -49,10 +49,10 @@ public function testRequest(): void 'success' => true, 'reports' => [ 'test' => [ - 'a' => 'b' - ] - ] - ] + 'a' => 'b', + ], + ], + ], ], JSON_THROW_ON_ERROR)); $this->client->method('sendRequest') ->willReturn($this->response); @@ -62,13 +62,13 @@ public function testRequest(): void $expected = CheckStatus::createSuccess(); $expected->addReport('test', [ - 'a' => 'b' + 'a' => 'b', ]); $this->assertEquals( $expected, $status, - 'Unexpected CheckStatus' + 'Unexpected CheckStatus', ); } @@ -86,13 +86,13 @@ public function testRequestMissingFpmFcgi(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'fpm-fcgi', - 'No FastCGI status found in response.' + 'No FastCGI status found in response.', ); $this->assertEquals( $expected, $status, - 'Unexpected CheckStatus' + 'Unexpected CheckStatus', ); } public function testRequestWithInvalidJson(): void @@ -107,13 +107,13 @@ public function testRequestWithInvalidJson(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'fpm-fcgi', - "JSON error: Syntax error\ninvalid-json" + "JSON error: Syntax error\ninvalid-json", ); $this->assertEquals( $expected, $status, - 'Unexpected CheckStatus' + 'Unexpected CheckStatus', ); } @@ -127,13 +127,13 @@ public function testRequestWithException(): void $expected = CheckStatus::createFailure(); $expected->addMessage( 'fpm-fcgi', - 'FastCGI error: error (mysocket)' + 'FastCGI error: error (mysocket)', ); $this->assertEquals( $expected, $status, - 'Unexpected CheckStatus' + 'Unexpected CheckStatus', ); } } diff --git a/test/Service/Cli/FastCgiStatusFactoryTest.php b/test/Service/Cli/FastCgiStatusFactoryTest.php index 54195e9..9bc4188 100644 --- a/test/Service/Cli/FastCgiStatusFactoryTest.php +++ b/test/Service/Cli/FastCgiStatusFactoryTest.php @@ -13,7 +13,7 @@ class FastCgiStatusFactoryTest extends TestCase { private string $resourceDir = __DIR__ - . '/../../resources/Service/Cli/FastCgiStatusFactoryTest'; + . '/../../resources/Service/Cli/FastCgiStatusFactoryTest'; public function testCreateWithDefaultSocket(): void { @@ -21,14 +21,14 @@ public function testCreateWithDefaultSocket(): void possibleSocketFilePatterns: [], frontControllerPath: 'test', resourceRoot: 'test', - resourceHost: 'test' + resourceHost: 'test', ); $status = $factory->create(); $this->assertEquals( '127.0.0.1:9000', $status->getSocket(), - 'Unexpected socket' + 'Unexpected socket', ); } @@ -38,14 +38,14 @@ public function testCreateWithGivenSocket(): void possibleSocketFilePatterns: [], frontControllerPath: 'test', resourceRoot: 'test', - resourceHost: 'test' + resourceHost: 'test', ); $status = $factory->create('1.2.3.4:9000'); $this->assertEquals( '1.2.3.4:9000', $status->getSocket(), - 'Unexpected socket' + 'Unexpected socket', ); } @@ -53,11 +53,11 @@ public function testCreateWithUnixSocket(): void { $factory = new FastCgiStatusFactory( possibleSocketFilePatterns: [ - $this->resourceDir . '/unix-*' + $this->resourceDir . '/unix-*', ], frontControllerPath: 'test', resourceRoot: 'test', - resourceHost: 'test' + resourceHost: 'test', ); $status = $factory->create(); @@ -65,7 +65,7 @@ public function testCreateWithUnixSocket(): void $this->assertEquals( $this->resourceDir . '/unix-socket', $status->getSocket(), - 'Unexpected socket' + 'Unexpected socket', ); } @@ -76,7 +76,7 @@ public function testWithNullResourceRoot(): void possibleSocketFilePatterns: [], frontControllerPath: 'test', resourceRoot: null, - resourceHost: 'test' + resourceHost: 'test', ); } @@ -87,7 +87,7 @@ public function testWithNullResourceHost(): void possibleSocketFilePatterns: [], frontControllerPath: 'test', resourceRoot: 'test', - resourceHost: null + resourceHost: null, ); } } diff --git a/test/Service/Cli/RuntimeCheckTest.php b/test/Service/Cli/RuntimeCheckTest.php index bfb2c2d..cd37501 100644 --- a/test/Service/Cli/RuntimeCheckTest.php +++ b/test/Service/Cli/RuntimeCheckTest.php @@ -47,7 +47,7 @@ public function testCheck(): void $runtimeCheck = new RuntimeCheck( $checkerCollection, $fastCgiStatusFactory, - $workerStatusFile + $workerStatusFile, ); $runtimeStatus = $runtimeCheck->execute([], null); @@ -59,7 +59,7 @@ public function testCheck(): void $this->assertEquals( $expected, $runtimeStatus, - 'Runtime status is not as expected' + 'Runtime status is not as expected', ); } @@ -75,7 +75,7 @@ public function testCheckSkip(): void $runtimeCheck = new RuntimeCheck( $checkerCollection, $fastCgiStatusFactory, - $workerStatusFile + $workerStatusFile, ); $runtimeStatus = $runtimeCheck->execute([ RuntimeType::CLI->value, @@ -88,7 +88,7 @@ public function testCheckSkip(): void $this->assertEquals( $expected, $runtimeStatus, - 'Runtime status is not as expected' + 'Runtime status is not as expected', ); } } diff --git a/test/Service/FpmFcgi/CliStatusTest.php b/test/Service/FpmFcgi/CliStatusTest.php index 2ef662e..ec4a3f4 100644 --- a/test/Service/FpmFcgi/CliStatusTest.php +++ b/test/Service/FpmFcgi/CliStatusTest.php @@ -20,7 +20,7 @@ public function testExecuteSuccess(): void $checkStatus = $cliStatus->execute([]); $this->assertTrue( $checkStatus->success, - 'CheckStatus should be successful' + 'CheckStatus should be successful', ); } @@ -31,7 +31,7 @@ public function testExecuteMissingCliStatus(): void $checkStatus = $cliStatus->execute([]); $this->assertFalse( $checkStatus->success, - 'CheckStatus should not be successful' + 'CheckStatus should not be successful', ); } @@ -42,7 +42,7 @@ public function testExecuteWithExitCode1(): void $checkStatus = $cliStatus->execute([]); $this->assertFalse( $checkStatus->success, - 'CheckStatus should be successful' + 'CheckStatus should be successful', ); } } diff --git a/test/Service/FpmFcgi/RuntimeCheckTest.php b/test/Service/FpmFcgi/RuntimeCheckTest.php index acdac72..98b248c 100644 --- a/test/Service/FpmFcgi/RuntimeCheckTest.php +++ b/test/Service/FpmFcgi/RuntimeCheckTest.php @@ -38,7 +38,7 @@ public function testCheck(): void $runtimeCheck = new RuntimeCheck( $checkerCollection, $cliStatus, - $workerStatusFile + $workerStatusFile, ); $runtimeStatus = $runtimeCheck->execute([]); @@ -50,7 +50,7 @@ public function testCheck(): void $this->assertEquals( $expected, $runtimeStatus, - 'Runtime status is not as expected' + 'Runtime status is not as expected', ); } @@ -63,7 +63,7 @@ public function testCheckSkip(): void $runtimeCheck = new RuntimeCheck( $checkerCollection, $cliStatus, - $workerStatusFile + $workerStatusFile, ); $runtimeStatus = $runtimeCheck->execute([ RuntimeType::FPM_FCGI->value, @@ -76,7 +76,7 @@ public function testCheckSkip(): void $this->assertEquals( $expected, $runtimeStatus, - 'Runtime status is not as expected' + 'Runtime status is not as expected', ); } } diff --git a/test/Service/RuntimeStatusTest.php b/test/Service/RuntimeStatusTest.php index 40a6d62..ecc2b1e 100644 --- a/test/Service/RuntimeStatusTest.php +++ b/test/Service/RuntimeStatusTest.php @@ -23,7 +23,7 @@ public function testAddStatus(): void $this->assertEquals( $checkStatus, $runtimeStatus->getStatus(RuntimeType::CLI), - 'Status is not as expected' + 'Status is not as expected', ); } @@ -32,17 +32,17 @@ public function testGetTypes(): void $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus( RuntimeType::CLI, - CheckStatus::createSuccess() + CheckStatus::createSuccess(), ); $runtimeStatus->addStatus( RuntimeType::WORKER, - CheckStatus::createSuccess() + CheckStatus::createSuccess(), ); $this->assertEquals( [RuntimeType::CLI, RuntimeType::WORKER], $runtimeStatus->getTypes(), - 'Unexpected types' + 'Unexpected types', ); } @@ -51,12 +51,12 @@ public function testIsSuccess(): void $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus( RuntimeType::CLI, - CheckStatus::createSuccess() + CheckStatus::createSuccess(), ); $this->assertTrue( $runtimeStatus->isSuccess(), - 'Status should be successful' + 'Status should be successful', ); } @@ -65,16 +65,16 @@ public function testIsNotSuccess(): void $runtimeStatus = new RuntimeStatus(); $runtimeStatus->addStatus( RuntimeType::CLI, - CheckStatus::createSuccess() + CheckStatus::createSuccess(), ); $runtimeStatus->addStatus( RuntimeType::WORKER, - CheckStatus::createFailure() + CheckStatus::createFailure(), ); $this->assertFalse( $runtimeStatus->isSuccess(), - 'Status should not be successful' + 'Status should not be successful', ); } @@ -88,7 +88,7 @@ public function testGetMessages(): void $this->assertEquals( ['cli/test: message'], $runtimeStatus->getMessages(), - 'Messages are not as expected' + 'Messages are not as expected', ); } @@ -108,10 +108,10 @@ public function testSerialize(): void 'messages' => ['test' => ['message']], ], 'success' => true, - 'messages' => ['cli/test: message'] + 'messages' => ['cli/test: message'], ], $runtimeStatus->serialize(), - 'Status is not as expected' + 'Status is not as expected', ); } @@ -124,7 +124,7 @@ public function testDeserialize(): void 'messages' => ['test' => ['message']], ], 'success' => true, - 'messages' => ['cli/test: message'] + 'messages' => ['cli/test: message'], ]; $checkStatus = CheckStatus::createSuccess() @@ -136,7 +136,7 @@ public function testDeserialize(): void $this->assertEquals( $expected, RuntimeStatus::deserialize($data), - 'Status is not as expected' + 'Status is not as expected', ); } } diff --git a/test/Service/RuntimeTypeTest.php b/test/Service/RuntimeTypeTest.php index dfc576a..f1e88cb 100644 --- a/test/Service/RuntimeTypeTest.php +++ b/test/Service/RuntimeTypeTest.php @@ -17,7 +17,7 @@ public function testOtherCases(): void $this->assertEquals( [RuntimeType::FPM_FCGI, RuntimeType::WORKER], $cases, - 'Cases are not as expected' + 'Cases are not as expected', ); } } diff --git a/test/Service/Worker/OneTimeTriggerTest.php b/test/Service/Worker/OneTimeTriggerTest.php index 12a1289..f965bd4 100644 --- a/test/Service/Worker/OneTimeTriggerTest.php +++ b/test/Service/Worker/OneTimeTriggerTest.php @@ -17,7 +17,7 @@ public function testToString(): void $this->assertEquals( 'one time', - (string) $trigger + (string) $trigger, ); } @@ -28,7 +28,7 @@ public function testToStringAlreadyRunning(): void $this->assertEquals( 'one time (already running)', - (string) $trigger + (string) $trigger, ); } @@ -40,7 +40,7 @@ public function testGetNextRunDate(): void $this->assertEquals( $run, $trigger->getNextRunDate($run), - 'The first call to getNextRunDate should return the same date' + 'The first call to getNextRunDate should return the same date', ); } @@ -52,7 +52,7 @@ public function testSecondGetNextRunDate(): void $this->assertNull( $trigger->getNextRunDate($run), - 'The second call to getNextRunDate should return null' + 'The second call to getNextRunDate should return null', ); } } diff --git a/test/Service/Worker/WorkerCheckSchedulerTest.php b/test/Service/Worker/WorkerCheckSchedulerTest.php index c58284f..9bb86b2 100644 --- a/test/Service/Worker/WorkerCheckSchedulerTest.php +++ b/test/Service/Worker/WorkerCheckSchedulerTest.php @@ -25,14 +25,14 @@ public function testGetSchedule(): void $workerStatusFile, $checkerCollection, 'www', - $lockFactory + $lockFactory, ); $schedule = $workerCheckScheduler->getSchedule(); $this->assertEquals( 2, - count($schedule->getRecurringMessages()) + count($schedule->getRecurringMessages()), ); } @@ -49,7 +49,7 @@ public function testInvoke(): void $workerStatusFile, $checkerCollection, 'www', - $lockFactory + $lockFactory, ); diff --git a/test/Service/Worker/WorkerStatusFileTest.php b/test/Service/Worker/WorkerStatusFileTest.php index 5bb536a..e8c5cad 100644 --- a/test/Service/Worker/WorkerStatusFileTest.php +++ b/test/Service/Worker/WorkerStatusFileTest.php @@ -45,7 +45,7 @@ public function tearDown(): void public function testRead(): void { $date = new DateTime( - '2024-06-10 13:31:00' + '2024-06-10 13:31:00', ); $platform = $this->createStub(Platform::class); $platform->method('time') @@ -54,26 +54,26 @@ public function testRead(): void $statusFile = new WorkerStatusFile( $this->resourceDir . '/statusFile.json', 10, - $platform + $platform, ); $status = $statusFile->read(); $expected = CheckStatus::createSuccess(); $expected->addReport('scheduler', [ - 'last-run' => '10.06.2024 13:16:00' + 'last-run' => '10.06.2024 13:16:00', ]); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } public function testReadWithEmptyStatusFile(): void { $date = new DateTime( - '2024-06-10 13:31:00' + '2024-06-10 13:31:00', ); $platform = $this->createStub(Platform::class); $platform->method('time') @@ -82,7 +82,7 @@ public function testReadWithEmptyStatusFile(): void $statusFile = new WorkerStatusFile( $this->resourceDir . '/empty-statusFile.json', 10, - $platform + $platform, ); $status = $statusFile->read(); @@ -90,13 +90,13 @@ public function testReadWithEmptyStatusFile(): void $expected->addMessage( 'scheduler', 'The worker did not run in the last 10 minutes.' - . ' Last run: unknown' + . ' Last run: unknown', ); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } public function testReadFileNotExists(): void @@ -113,7 +113,7 @@ public function testReadFileNotExists(): void $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } @@ -139,7 +139,7 @@ public function testReadFileNotReadable(): void public function testReadFileLastRunExpired(): void { $date = new DateTime( - '2024-06-10 13:32:00' + '2024-06-10 13:32:00', ); $platform = $this->createStub(Platform::class); $platform->method('time') @@ -148,31 +148,31 @@ public function testReadFileLastRunExpired(): void $statusFile = new WorkerStatusFile( $this->resourceDir . '/statusFile.json', 10, - $platform + $platform, ); $status = $statusFile->read(); $expected = CheckStatus::createFailure(); $expected->addReport('scheduler', [ - 'last-run' => '10.06.2024 13:16:00' + 'last-run' => '10.06.2024 13:16:00', ]); $expected->addMessage( 'scheduler', 'The worker did not run in the last 10 minutes.' - . ' Last run: 10.06.2024 13:16:00' + . ' Last run: 10.06.2024 13:16:00', ); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } public function testReadWithInvalidLastRun(): void { $date = new DateTime( - '2024-06-10 13:16:00' + '2024-06-10 13:16:00', ); $platform = $this->createStub(Platform::class); $platform->method('time') @@ -181,24 +181,24 @@ public function testReadWithInvalidLastRun(): void $statusFile = new WorkerStatusFile( $this->resourceDir . '/statusFileWithInvalidLastRun.json', 10, - $platform + $platform, ); $status = $statusFile->read(); $expected = CheckStatus::createFailure(); $expected->addReport('scheduler', [ - 'last-run' => 123 + 'last-run' => 123, ]); $expected->addMessage( 'scheduler', 'The worker did not run in the last 10 minutes.' - . ' Last run: 123' + . ' Last run: 123', ); $this->assertEquals( $expected, $status, - 'Unexpected status' + 'Unexpected status', ); } @@ -210,7 +210,7 @@ public function testWrite(): void { $date = new DateTime( - '2024-06-10 13:32:00' + '2024-06-10 13:32:00', ); $platform = $this->createStub(Platform::class); $platform->method('time') @@ -220,12 +220,12 @@ public function testWrite(): void $statusFile = new WorkerStatusFile( $file, 10, - $platform + $platform, ); $checkStatus = CheckStatus::createSuccess(); $checkStatus->addReport('test', [ - 'a' => 'b' + 'a' => 'b', ]); try { @@ -243,7 +243,7 @@ public function testWrite(): void file_get_contents($file), true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $this->assertEquals( @@ -251,19 +251,19 @@ public function testWrite(): void 'success' => true, 'reports' => [ 'test' => [ - 'a' => 'b' + 'a' => 'b', ], 'supervisor' => [ 'group' => 'worker', - 'process' => 'worker_01' + 'process' => 'worker_01', ], 'scheduler' => [ - 'last-run' => '10.06.2024 13:32:00' + 'last-run' => '10.06.2024 13:32:00', ], - ] + ], ], $writtenData, - 'Unexpected status' + 'Unexpected status', ); } }