From cce3dbd74f8fe0c0ef01f3c4c13a981a5b4482de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 3 Dec 2024 16:21:25 +0100 Subject: [PATCH] upgrade to PHP 8.3 --- .github/workflows/continuous-integration.yml | 10 +++--- .php-cs-fixer.php | 6 ++-- composer.json | 8 ++--- phpmd.ruleset.xml | 36 -------------------- phpstan.neon | 4 +-- phpunit.xml | 4 ++- rector.php | 2 +- src/Module.php | 2 ++ src/StreamFormatter.php | 19 ++++++----- src/StreamFormatterFactory.php | 6 ++-- tests/ConfigProviderTest.php | 2 ++ 11 files changed, 38 insertions(+), 61 deletions(-) delete mode 100644 phpmd.ruleset.xml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 6c653f7..bbb013b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,7 +19,7 @@ jobs: validate: name: "Validate Project" - uses: "mimmi20/ci/.github/workflows/validate.yml@8.1" + uses: "mimmi20/ci/.github/workflows/validate.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -37,7 +37,7 @@ jobs: needs: "validate" - uses: "mimmi20/ci/.github/workflows/install.yml@8.1" + uses: "mimmi20/ci/.github/workflows/install.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -50,7 +50,7 @@ jobs: needs: "install" - uses: "mimmi20/ci/.github/workflows/analytics.yml@8.1" + uses: "mimmi20/ci/.github/workflows/analytics.yml@8.3" with: extensions: "ctype, curl, dom, iconv, intl, mbstring, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" @@ -59,7 +59,7 @@ jobs: skip-phpcs: false skip-phpstan: false skip-rector: false - skip-phpmd: false + skip-phpmd: true skip-eslint: true skip-stylelint: true skip-prettier: true @@ -70,7 +70,7 @@ jobs: needs: "analytics" - uses: "mimmi20/ci/.github/workflows/test.yml@8.1" + uses: "mimmi20/ci/.github/workflows/test.yml@8.3" with: extensions: "ctype, dom, fileinfo, intl, simplexml, tokenizer, xml, xmlwriter" ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 493914a..ddafddc 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,10 +11,12 @@ declare(strict_types = 1); -$header = <<<'EOF' +$year = date('Y'); + +$header = << + Copyright (c) 2022-{$year}, Thomas Mueller For the full copyright and license information, please view the LICENSE file that was distributed with this source code. diff --git a/composer.json b/composer.json index 01f02cc..c58a462 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "source": "https://github.com/mimmi20/monolog-streamformatter" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || 8.5.0", + "php": "~8.3.0 || ~8.4.0 || 8.5.0", "ext-mbstring": "*", "monolog/monolog": "^3.8.0", "psr/container": "^1.1.2 || ^2.0.2", @@ -33,16 +33,16 @@ "infection/infection": "^0.29.8", "laminas/laminas-modulemanager": "^2.17.0", "laminas/laminas-servicemanager": "^3.22.1", - "mimmi20/coding-standard": "^5.2.45", + "mimmi20/coding-standard": "^6.0.0", "nikic/php-parser": "^5.3.1", "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^1.12.9", "phpstan/phpstan-deprecation-rules": "^1.2.1", "phpstan/phpstan-phpunit": "^1.4.0", - "phpunit/phpunit": "^10.5.25", + "phpunit/phpunit": "^11.4.4", "rector/rector": "^1.2.10", "rector/type-perfect": "^1.0.0", - "symfony/process": "^6.4.15", + "symfony/process": "^7.2.0", "symplify/phpstan-rules": "^13.0.1", "tomasvotruba/cognitive-complexity": "^0.2.3", "tomasvotruba/type-coverage": "^1.0.0", diff --git a/phpmd.ruleset.xml b/phpmd.ruleset.xml deleted file mode 100644 index b7ce722..0000000 --- a/phpmd.ruleset.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - The coding standard. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/phpstan.neon b/phpstan.neon index eb05bfa..fe78327 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: level: max - phpVersion: 80100 # PHP 8.1 + phpVersion: 80300 # PHP 8.3 parallel: maximumNumberOfProcesses: 1 @@ -104,7 +104,7 @@ parameters: return_type: 100 param_type: 98.4 property_type: 100 - constant_type: 0 + constant_type: 100 # also, how many files has declare strict types declare: 100 diff --git a/phpunit.xml b/phpunit.xml index c0fab4c..4db5a32 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,12 +9,14 @@ beStrictAboutCoverageMetadata="false" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" + displayDetailsOnPhpunitDeprecations="true" displayDetailsOnTestsThatTriggerWarnings="true" displayDetailsOnTestsThatTriggerNotices="true" displayDetailsOnTestsThatTriggerErrors="true" displayDetailsOnTestsThatTriggerDeprecations="true" displayDetailsOnSkippedTests="true" displayDetailsOnIncompleteTests="true" + failOnPhpunitDeprecation="true" failOnEmptyTestSuite="true" failOnIncomplete="true" failOnRisky="true" @@ -51,7 +53,7 @@ - + diff --git a/rector.php b/rector.php index a4e4291..ae57f5e 100644 --- a/rector.php +++ b/rector.php @@ -29,7 +29,7 @@ $rectorConfig->sets([ SetList::DEAD_CODE, - LevelSetList::UP_TO_PHP_81, + LevelSetList::UP_TO_PHP_83, PHPUnitSetList::PHPUNIT_100, ]); diff --git a/src/Module.php b/src/Module.php index a560975..d97bb64 100644 --- a/src/Module.php +++ b/src/Module.php @@ -14,6 +14,7 @@ namespace Mimmi20\Monolog\Formatter; use Laminas\ModuleManager\Feature\ConfigProviderInterface; +use Override; final class Module implements ConfigProviderInterface { @@ -25,6 +26,7 @@ final class Module implements ConfigProviderInterface * * @throws void */ + #[Override] public function getConfig(): array { $provider = new ConfigProvider(); diff --git a/src/StreamFormatter.php b/src/StreamFormatter.php index bdc4799..e1c2e52 100644 --- a/src/StreamFormatter.php +++ b/src/StreamFormatter.php @@ -17,6 +17,7 @@ use Monolog\Formatter\NormalizerFormatter; use Monolog\Level; use Monolog\LogRecord; +use Override; use RuntimeException; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableCell; @@ -37,28 +38,28 @@ final class StreamFormatter extends NormalizerFormatter { /** @api */ - public const SIMPLE_FORMAT = '%message%'; + public const string SIMPLE_FORMAT = '%message%'; /** @api */ - public const BOX_STYLE = 'box'; + public const string BOX_STYLE = 'box'; /** @api */ - public const WIDTH_FIRST_COLUMN = 20; + public const int WIDTH_FIRST_COLUMN = 20; /** @api */ - public const WIDTH_SECOND_COLUMN = 20; + public const int WIDTH_SECOND_COLUMN = 20; /** @api */ - public const WIDTH_THIRD_COLUMN = 220; + public const int WIDTH_THIRD_COLUMN = 220; /** @api */ - public const FULL_WIDTH = self::WIDTH_FIRST_COLUMN + self::WIDTH_SECOND_COLUMN + self::WIDTH_THIRD_COLUMN + 10; + public const int FULL_WIDTH = self::WIDTH_FIRST_COLUMN + self::WIDTH_SECOND_COLUMN + self::WIDTH_THIRD_COLUMN + 10; /** @api */ - public const SPAN_ALL_COLUMS = 3; + public const int SPAN_ALL_COLUMS = 3; /** @api */ - public const SPAN_LAST_COLUMNS = 2; + public const int SPAN_LAST_COLUMNS = 2; private readonly string $format; private bool $allowInlineLineBreaks; @@ -141,6 +142,7 @@ public function setFormatter(LineFormatter $formatter): void * * @throws RuntimeException if encoding fails and errors are not ignored */ + #[Override] public function format(LogRecord $record): string { $message = $this->getFormatter()->format($record); @@ -199,6 +201,7 @@ public function format(LogRecord $record): string * * @throws RuntimeException if encoding fails and errors are not ignored */ + #[Override] public function formatBatch(array $records): string { $message = ''; diff --git a/src/StreamFormatterFactory.php b/src/StreamFormatterFactory.php index 628485e..823a664 100644 --- a/src/StreamFormatterFactory.php +++ b/src/StreamFormatterFactory.php @@ -14,6 +14,7 @@ namespace Mimmi20\Monolog\Formatter; use Laminas\ServiceManager\Factory\FactoryInterface; +use Override; use Psr\Container\ContainerInterface; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Output\BufferedOutput; @@ -24,10 +25,10 @@ final class StreamFormatterFactory implements FactoryInterface { /** @api */ - public const DEFAULT_NORMALIZER_DEPTH = 9; + public const int DEFAULT_NORMALIZER_DEPTH = 9; /** @api */ - public const DEFAULT_NORMALIZER_ITEM_COUNT = 1000; + public const int DEFAULT_NORMALIZER_ITEM_COUNT = 1000; /** * @param string $requestedName @@ -39,6 +40,7 @@ final class StreamFormatterFactory implements FactoryInterface * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint */ + #[Override] public function __invoke( ContainerInterface $container, $requestedName, diff --git a/tests/ConfigProviderTest.php b/tests/ConfigProviderTest.php index b21948d..bc397fa 100644 --- a/tests/ConfigProviderTest.php +++ b/tests/ConfigProviderTest.php @@ -14,6 +14,7 @@ namespace Mimmi20Test\Monolog\Formatter; use Mimmi20\Monolog\Formatter\ConfigProvider; +use Override; use PHPUnit\Framework\Exception; use PHPUnit\Framework\TestCase; @@ -22,6 +23,7 @@ final class ConfigProviderTest extends TestCase private ConfigProvider $provider; /** @throws void */ + #[Override] protected function setUp(): void { $this->provider = new ConfigProvider();