From 5c609241557009c6b7602d344b2de7cd4eff732c Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Wed, 3 Sep 2025 01:03:36 +0300 Subject: [PATCH 1/5] chore: update PHP-CS-Fixer --- ci/php-cs-fixer/config.php | 2 ++ composer.json | 2 +- src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php | 2 +- src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php | 2 +- .../Utils/PostgresJsonToPHPArrayTransformer.php | 2 +- tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/JsonbTest.php | 4 ++-- .../Utils/PostgresJsonToPHPArrayTransformerTest.php | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ci/php-cs-fixer/config.php b/ci/php-cs-fixer/config.php index 8567404d..ceed386a 100644 --- a/ci/php-cs-fixer/config.php +++ b/ci/php-cs-fixer/config.php @@ -54,6 +54,8 @@ ) ->setRiskyAllowed(true) ->setUsingCache(false) + ->setParallelisation() + ->setUnsupportedPhpVersionAllowed(true) ->setIndent(' ') ->setLineEnding("\n") ->setFinder($finder); diff --git a/composer.json b/composer.json index 49842cef..6f185044 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "deptrac analyze --config-file=./ci/deptrac/config.yml --cache-file=./ci/deptrac/.cache --no-interaction --no-progress" ], "php-cs-fixer": [ - "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=./ci/php-cs-fixer/config.php --show-progress=none --no-interaction --diff -v" + "php-cs-fixer fix --config=./ci/php-cs-fixer/config.php --show-progress=none --no-interaction --diff -v" ], "phpstan": [ "phpstan analyse --configuration=./ci/phpstan/config.neon" diff --git a/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php b/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php index d1c75e84..7008f3af 100644 --- a/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php +++ b/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php @@ -32,7 +32,7 @@ protected function transformToPostgresJson(mixed $phpValue): string return $postgresValue; } - protected function transformFromPostgresJson(string $postgresValue): null|array|bool|float|int|string + protected function transformFromPostgresJson(string $postgresValue): array|bool|float|int|string|null { return PostgresJsonToPHPArrayTransformer::transformPostgresJsonEncodedValueToPHPValue($postgresValue); } diff --git a/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php b/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php index 34e75385..6bdd73b7 100644 --- a/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php +++ b/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php @@ -42,7 +42,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str * * @param string|null $value the value to convert */ - public function convertToPHPValue($value, AbstractPlatform $platform): null|array|bool|float|int|string + public function convertToPHPValue($value, AbstractPlatform $platform): array|bool|float|int|string|null { if ($value === null) { return null; diff --git a/src/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformer.php b/src/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformer.php index da55e048..9718f188 100644 --- a/src/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformer.php +++ b/src/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformer.php @@ -53,7 +53,7 @@ public static function transformPostgresJsonEncodedValueToPHPArray(string $postg /** * @throws InvalidJsonItemForPHPException When the PostgreSQL value is not JSON-decodable */ - public static function transformPostgresJsonEncodedValueToPHPValue(string $postgresValue): null|array|bool|float|int|string + public static function transformPostgresJsonEncodedValueToPHPValue(string $postgresValue): array|bool|float|int|string|null { try { // @phpstan-ignore-next-line diff --git a/tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/JsonbTest.php b/tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/JsonbTest.php index e09c9c2f..c68638a2 100644 --- a/tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/JsonbTest.php +++ b/tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/JsonbTest.php @@ -37,14 +37,14 @@ public function has_name(): void #[DataProvider('provideValidTransformations')] #[Test] - public function can_transform_from_php_value(null|array|bool|float|int|string $phpValue, ?string $postgresValue): void + public function can_transform_from_php_value(array|bool|float|int|string|null $phpValue, ?string $postgresValue): void { $this->assertEquals($postgresValue, $this->fixture->convertToDatabaseValue($phpValue, $this->platform)); } #[DataProvider('provideValidTransformations')] #[Test] - public function can_transform_to_php_value(null|array|bool|float|int|string $phpValue, ?string $postgresValue): void + public function can_transform_to_php_value(array|bool|float|int|string|null $phpValue, ?string $postgresValue): void { $this->assertEquals($phpValue, $this->fixture->convertToPHPValue($postgresValue, $this->platform)); } diff --git a/tests/Unit/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformerTest.php b/tests/Unit/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformerTest.php index 65a4e8c4..aad9d8ac 100644 --- a/tests/Unit/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformerTest.php +++ b/tests/Unit/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformerTest.php @@ -15,7 +15,7 @@ class PostgresJsonToPHPArrayTransformerTest extends TestCase { #[DataProvider('provideValidJsonTransformations')] #[Test] - public function can_transform_json_to_php_value(null|array|bool|int|string $phpValue, string $postgresValue): void + public function can_transform_json_to_php_value(array|bool|int|string|null $phpValue, string $postgresValue): void { $this->assertEquals($phpValue, PostgresJsonToPHPArrayTransformer::transformPostgresJsonEncodedValueToPHPValue($postgresValue)); } From 370b283cf2c5173840facd3a18d9605cd604ba88 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 2 Sep 2025 23:17:12 +0100 Subject: [PATCH 2/5] Update composer.json Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6f185044..c7daab01 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "deptrac analyze --config-file=./ci/deptrac/config.yml --cache-file=./ci/deptrac/.cache --no-interaction --no-progress" ], "php-cs-fixer": [ - "php-cs-fixer fix --config=./ci/php-cs-fixer/config.php --show-progress=none --no-interaction --diff -v" + "php-cs-fixer fix --config=./ci/php-cs-fixer/config.php --allow-unsupported-php-version=yes --show-progress=none --no-interaction --diff -v" ], "phpstan": [ "phpstan analyse --configuration=./ci/phpstan/config.neon" From 54b7910dc659fbab65ae41bbf2ec7bc758035e85 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 2 Sep 2025 23:18:10 +0100 Subject: [PATCH 3/5] Update ci/php-cs-fixer/config.php vibe code it :) --- ci/php-cs-fixer/config.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/php-cs-fixer/config.php b/ci/php-cs-fixer/config.php index ceed386a..c1bf425f 100644 --- a/ci/php-cs-fixer/config.php +++ b/ci/php-cs-fixer/config.php @@ -54,8 +54,7 @@ ) ->setRiskyAllowed(true) ->setUsingCache(false) - ->setParallelisation() - ->setUnsupportedPhpVersionAllowed(true) + ->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setIndent(' ') ->setLineEnding("\n") ->setFinder($finder); From 2f45564830525452c82abcf377cbbd45b5ab259e Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 2 Sep 2025 23:20:03 +0100 Subject: [PATCH 4/5] Update config.php --- ci/php-cs-fixer/config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/php-cs-fixer/config.php b/ci/php-cs-fixer/config.php index c1bf425f..48f36011 100644 --- a/ci/php-cs-fixer/config.php +++ b/ci/php-cs-fixer/config.php @@ -4,6 +4,7 @@ use PhpCsFixer\Config; use PhpCsFixer\Finder; +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; $basePath = __DIR__.'/../../'; @@ -54,7 +55,7 @@ ) ->setRiskyAllowed(true) ->setUsingCache(false) - ->setParallelConfig(\PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) + ->setParallelConfig(ParallelConfigFactory::detect()) ->setIndent(' ') ->setLineEnding("\n") ->setFinder($finder); From eff9aab5601255617afb0ae151609f937c22c021 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Wed, 3 Sep 2025 01:33:54 +0300 Subject: [PATCH 5/5] no message --- ci/php-cs-fixer/config.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ci/php-cs-fixer/config.php b/ci/php-cs-fixer/config.php index 48f36011..59dc9edf 100644 --- a/ci/php-cs-fixer/config.php +++ b/ci/php-cs-fixer/config.php @@ -14,9 +14,7 @@ ->in($basePath.'src') ->in($basePath.'tests'); -$config = new Config(); - -return $config +$config = (new Config()) ->setRules( [ '@PSR2' => true, @@ -55,7 +53,13 @@ ) ->setRiskyAllowed(true) ->setUsingCache(false) - ->setParallelConfig(ParallelConfigFactory::detect()) + ->setIndent(' ') ->setLineEnding("\n") ->setFinder($finder); + +if (\method_exists($config, 'setParallelConfig')) { + $config->setParallelConfig(ParallelConfigFactory::detect()); +} + +return $config;