From 30f2ae64e86aa6d5cfcf07f0d4c3b044fba4c9af Mon Sep 17 00:00:00 2001 From: sebprt Date: Thu, 25 May 2023 15:01:22 +0200 Subject: [PATCH 01/10] Created new functions to manage reference entities --- src/AkeneoBuilderProvider.php | 2 ++ src/WithReferenceEntitySimpleOption.php | 48 +++++++++++++++++++++++++ src/WithReferenceEntityValue.php | 31 ++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/WithReferenceEntitySimpleOption.php create mode 100644 src/WithReferenceEntityValue.php diff --git a/src/AkeneoBuilderProvider.php b/src/AkeneoBuilderProvider.php index d64105d..a6f2905 100644 --- a/src/AkeneoBuilderProvider.php +++ b/src/AkeneoBuilderProvider.php @@ -13,6 +13,8 @@ public function getFunctions(): array return [ new Build('build'), new WithValue('withValue'), + new WithReferenceEntityValue('withReferenceEntityValue'), + new WithReferenceEntitySimpleOption('withReferenceEntitySimpleOption'), new WithSimpleOption('withSimpleOption'), new WithMultipleOption('withMultipleOption'), ]; diff --git a/src/WithReferenceEntitySimpleOption.php b/src/WithReferenceEntitySimpleOption.php new file mode 100644 index 0000000..3d599fa --- /dev/null +++ b/src/WithReferenceEntitySimpleOption.php @@ -0,0 +1,48 @@ +compile(...)->bindTo($this), + $this->evaluate(...)->bindTo($this) + ); + } + + private function compile(string $code, string $locale = 'null', string $channel = 'null'): string + { + return << [ + $code + ], + 'locale' => $locale, + 'channel' => $channel, + ], + ]) + PHP; + } + + /** + * @var array $labels + */ + private function evaluate(array $context, string $code, ?string $locale = null, ?string $channel = null): array + { + return [[ + 'locale' => $locale, + 'channel' => $channel, + 'data' => [ + $code + ], + ]]; + } +} diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php new file mode 100644 index 0000000..fc3f087 --- /dev/null +++ b/src/WithReferenceEntityValue.php @@ -0,0 +1,31 @@ +compile(...)->bindTo($this), + $this->evaluate(...)->bindTo($this) + ); + } + + private function compile(string $value, string $locale = 'null', string $channel = 'null'): string + { + return sprintf('([["data" => (%s), "locale" => (%s), "channel" => (%s)]])', $value, $locale, $channel); + } + + private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array + { + return [[ + 'locale' => $locale, + 'channel' => $scope, + 'data' => $value, + ]]; + } +} From 1afe8365610e08938485c085561f75599e87ed6a Mon Sep 17 00:00:00 2001 From: sebprt Date: Thu, 25 May 2023 15:03:38 +0200 Subject: [PATCH 02/10] Ran php-cs-fixer --- src/WithReferenceEntitySimpleOption.php | 11 ++++------- src/WithReferenceEntityValue.php | 2 ++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/WithReferenceEntitySimpleOption.php b/src/WithReferenceEntitySimpleOption.php index 3d599fa..62cb37a 100644 --- a/src/WithReferenceEntitySimpleOption.php +++ b/src/WithReferenceEntitySimpleOption.php @@ -23,25 +23,22 @@ private function compile(string $code, string $locale = 'null', string $channel ([ [ 'data' => [ - $code + {$code} ], - 'locale' => $locale, - 'channel' => $channel, + 'locale' => {$locale}, + 'channel' => {$channel}, ], ]) PHP; } - /** - * @var array $labels - */ private function evaluate(array $context, string $code, ?string $locale = null, ?string $channel = null): array { return [[ 'locale' => $locale, 'channel' => $channel, 'data' => [ - $code + $code, ], ]]; } diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php index fc3f087..7c3a9ca 100644 --- a/src/WithReferenceEntityValue.php +++ b/src/WithReferenceEntityValue.php @@ -1,5 +1,7 @@ Date: Fri, 9 Jun 2023 10:48:36 +0200 Subject: [PATCH 03/10] Ran php-cs-fixer --- src/DateTime.php | 4 ++-- src/DateTimeZone.php | 4 ++-- src/WithMultipleOption.php | 2 +- src/WithReferenceEntitySimpleOption.php | 2 +- src/WithReferenceEntityValue.php | 2 +- src/WithSimpleOption.php | 2 +- src/WithValue.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/DateTime.php b/src/DateTime.php index be90f60..6363564 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, ?string $format = null): string + private function compile(string $date, string $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone("UTC"))', $date); @@ -26,7 +26,7 @@ private function compile(string $date, ?string $format = null): string return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone("UTC"))', $date, $format); } - private function evaluate(array $context, string $date, ?string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, string $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone('UTC')); diff --git a/src/DateTimeZone.php b/src/DateTimeZone.php index 6cf0335..93f5089 100644 --- a/src/DateTimeZone.php +++ b/src/DateTimeZone.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $zone, ?string $format = null): string + private function compile(string $date, string $zone, string $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone(%s))', $date, $zone); @@ -26,7 +26,7 @@ private function compile(string $date, string $zone, ?string $format = null): st return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone(%s))', $date, $format, $zone); } - private function evaluate(array $context, string $date, string $zone, ?string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, string $zone, string $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone($zone)); diff --git a/src/WithMultipleOption.php b/src/WithMultipleOption.php index 65fe654..8aedd62 100644 --- a/src/WithMultipleOption.php +++ b/src/WithMultipleOption.php @@ -48,7 +48,7 @@ function (string \$code) { /** * @return array> */ - private function evaluate(array $context, array $codes, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, array $codes, string $attribute, array $labels, string $locale = null, string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntitySimpleOption.php b/src/WithReferenceEntitySimpleOption.php index 62cb37a..ef0474e 100644 --- a/src/WithReferenceEntitySimpleOption.php +++ b/src/WithReferenceEntitySimpleOption.php @@ -32,7 +32,7 @@ private function compile(string $code, string $locale = 'null', string $channel PHP; } - private function evaluate(array $context, string $code, ?string $locale = null, ?string $channel = null): array + private function evaluate(array $context, string $code, string $locale = null, string $channel = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php index 7c3a9ca..12fe603 100644 --- a/src/WithReferenceEntityValue.php +++ b/src/WithReferenceEntityValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $channel return sprintf('([["data" => (%s), "locale" => (%s), "channel" => (%s)]])', $value, $locale, $channel); } - private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $value, string $locale = null, string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithSimpleOption.php b/src/WithSimpleOption.php index 35b37b0..db25fec 100644 --- a/src/WithSimpleOption.php +++ b/src/WithSimpleOption.php @@ -38,7 +38,7 @@ private function compile(string $code, string $attribute, string $labels, string /** * @return array|string|null>> */ - private function evaluate(array $context, string $code, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $code, string $attribute, array $labels, string $locale = null, string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithValue.php b/src/WithValue.php index 0f34b39..7a5bd58 100644 --- a/src/WithValue.php +++ b/src/WithValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $scope = return sprintf('([["data" => (%s), "locale" => (%s), "scope" => (%s)]])', $value, $locale, $scope); } - private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $value, string $locale = null, string $scope = null): array { return [[ 'locale' => $locale, From 30393ee3c205ae7f554dad2e964bd3cbec3307b7 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 12 Jun 2023 09:34:07 +0200 Subject: [PATCH 04/10] Ran php-cs-fixer --- .php-cs-fixer.dist.php | 1 + src/DateTime.php | 4 ++-- src/DateTimeZone.php | 4 ++-- src/WithMultipleOption.php | 2 +- src/WithReferenceEntitySimpleOption.php | 2 +- src/WithReferenceEntityValue.php | 2 +- src/WithSimpleOption.php | 2 +- src/WithValue.php | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 17eb868..798a78e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -35,6 +35,7 @@ 'error_suppression' => true, 'ereg_to_preg' => true, 'dir_constant' => true, + 'nullable_type_declaration_for_default_null_value' => true, ]) ->setFinder($finder) ->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line diff --git a/src/DateTime.php b/src/DateTime.php index 6363564..be90f60 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $format = null): string + private function compile(string $date, ?string $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone("UTC"))', $date); @@ -26,7 +26,7 @@ private function compile(string $date, string $format = null): string return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone("UTC"))', $date, $format); } - private function evaluate(array $context, string $date, string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, ?string $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone('UTC')); diff --git a/src/DateTimeZone.php b/src/DateTimeZone.php index 93f5089..6cf0335 100644 --- a/src/DateTimeZone.php +++ b/src/DateTimeZone.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $zone, string $format = null): string + private function compile(string $date, string $zone, ?string $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone(%s))', $date, $zone); @@ -26,7 +26,7 @@ private function compile(string $date, string $zone, string $format = null): str return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone(%s))', $date, $format, $zone); } - private function evaluate(array $context, string $date, string $zone, string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, string $zone, ?string $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone($zone)); diff --git a/src/WithMultipleOption.php b/src/WithMultipleOption.php index 8aedd62..65fe654 100644 --- a/src/WithMultipleOption.php +++ b/src/WithMultipleOption.php @@ -48,7 +48,7 @@ function (string \$code) { /** * @return array> */ - private function evaluate(array $context, array $codes, string $attribute, array $labels, string $locale = null, string $scope = null): array + private function evaluate(array $context, array $codes, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntitySimpleOption.php b/src/WithReferenceEntitySimpleOption.php index ef0474e..62cb37a 100644 --- a/src/WithReferenceEntitySimpleOption.php +++ b/src/WithReferenceEntitySimpleOption.php @@ -32,7 +32,7 @@ private function compile(string $code, string $locale = 'null', string $channel PHP; } - private function evaluate(array $context, string $code, string $locale = null, string $channel = null): array + private function evaluate(array $context, string $code, ?string $locale = null, ?string $channel = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php index 12fe603..7c3a9ca 100644 --- a/src/WithReferenceEntityValue.php +++ b/src/WithReferenceEntityValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $channel return sprintf('([["data" => (%s), "locale" => (%s), "channel" => (%s)]])', $value, $locale, $channel); } - private function evaluate(array $context, string $value, string $locale = null, string $scope = null): array + private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithSimpleOption.php b/src/WithSimpleOption.php index db25fec..35b37b0 100644 --- a/src/WithSimpleOption.php +++ b/src/WithSimpleOption.php @@ -38,7 +38,7 @@ private function compile(string $code, string $attribute, string $labels, string /** * @return array|string|null>> */ - private function evaluate(array $context, string $code, string $attribute, array $labels, string $locale = null, string $scope = null): array + private function evaluate(array $context, string $code, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithValue.php b/src/WithValue.php index 7a5bd58..0f34b39 100644 --- a/src/WithValue.php +++ b/src/WithValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $scope = return sprintf('([["data" => (%s), "locale" => (%s), "scope" => (%s)]])', $value, $locale, $scope); } - private function evaluate(array $context, string $value, string $locale = null, string $scope = null): array + private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array { return [[ 'locale' => $locale, From 8b77daa8ded1623cb5cb64b2cb8ed05b951a6ff0 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 12 Jun 2023 10:12:25 +0200 Subject: [PATCH 05/10] Updated GitHub actions --- .github/workflows/phpstan-5.yaml | 2 +- .github/workflows/phpstan-6.yaml | 2 +- .github/workflows/phpstan-7.yaml | 2 +- .github/workflows/phpstan-8.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-5.yaml index 906b4c9..f6dd9bf 100644 --- a/.github/workflows/phpstan-5.yaml +++ b/.github/workflows/phpstan-5.yaml @@ -1,7 +1,7 @@ name: PHPStan level 5 on: push jobs: - phpstan: + phpstan5: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/phpstan-6.yaml b/.github/workflows/phpstan-6.yaml index a367107..a0faf6b 100644 --- a/.github/workflows/phpstan-6.yaml +++ b/.github/workflows/phpstan-6.yaml @@ -1,7 +1,7 @@ name: PHPStan level 6 on: push jobs: - phpstan: + phpstan6: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/phpstan-7.yaml b/.github/workflows/phpstan-7.yaml index cad733d..c0a6ec6 100644 --- a/.github/workflows/phpstan-7.yaml +++ b/.github/workflows/phpstan-7.yaml @@ -1,7 +1,7 @@ name: PHPStan level 7 on: push jobs: - phpstan: + phpstan7: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/phpstan-8.yaml b/.github/workflows/phpstan-8.yaml index 8d7aec6..4fa22f1 100644 --- a/.github/workflows/phpstan-8.yaml +++ b/.github/workflows/phpstan-8.yaml @@ -1,7 +1,7 @@ name: PHPStan level 8 on: push jobs: - phpstan: + phpstan8: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From a8ed0b8f0f57397e3794825c1d0d85d7f83137d5 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 12 Jun 2023 10:33:37 +0200 Subject: [PATCH 06/10] Renamed argument --- src/WithReferenceEntityValue.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php index 7c3a9ca..86f1f7c 100644 --- a/src/WithReferenceEntityValue.php +++ b/src/WithReferenceEntityValue.php @@ -22,11 +22,11 @@ private function compile(string $value, string $locale = 'null', string $channel return sprintf('([["data" => (%s), "locale" => (%s), "channel" => (%s)]])', $value, $locale, $channel); } - private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $value, ?string $locale = null, ?string $channel = null): array { return [[ 'locale' => $locale, - 'channel' => $scope, + 'channel' => $channel, 'data' => $value, ]]; } From 5b973670915452e312d544f84dbd62cee5892af1 Mon Sep 17 00:00:00 2001 From: sebprt Date: Fri, 23 Jun 2023 11:19:54 +0200 Subject: [PATCH 07/10] Fixed syntax error in WithMultipleOption + ran php-cs-fixer --- src/DateTime.php | 4 ++-- src/DateTimeZone.php | 4 ++-- src/WithMultipleOption.php | 10 +++++----- src/WithReferenceEntitySimpleOption.php | 2 +- src/WithReferenceEntityValue.php | 2 +- src/WithSimpleOption.php | 2 +- src/WithValue.php | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/DateTime.php b/src/DateTime.php index be90f60..b4f6907 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, ?string $format = null): string + private function compile(string $date, string $format = 'null'): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone("UTC"))', $date); @@ -26,7 +26,7 @@ private function compile(string $date, ?string $format = null): string return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone("UTC"))', $date, $format); } - private function evaluate(array $context, string $date, ?string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, string|null $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone('UTC')); diff --git a/src/DateTimeZone.php b/src/DateTimeZone.php index 6cf0335..b0a9c2d 100644 --- a/src/DateTimeZone.php +++ b/src/DateTimeZone.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $zone, ?string $format = null): string + private function compile(string $date, string $zone, string $format = 'null'): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone(%s))', $date, $zone); @@ -26,7 +26,7 @@ private function compile(string $date, string $zone, ?string $format = null): st return sprintf('\DateTimeImmutable::createFromFormat(%s, %s, new \DateTimeZone(%s))', $date, $format, $zone); } - private function evaluate(array $context, string $date, string $zone, ?string $format = null): \DateTimeInterface + private function evaluate(array $context, string $date, string $zone, string|null $format = null): \DateTimeInterface { if (null === $format) { return new \DateTimeImmutable($date, new \DateTimeZone($zone)); diff --git a/src/WithMultipleOption.php b/src/WithMultipleOption.php index 65fe654..8466408 100644 --- a/src/WithMultipleOption.php +++ b/src/WithMultipleOption.php @@ -17,12 +17,12 @@ public function __construct($name) ); } - private function compile(string $codes, string $attribute, string $labels, string $locale, string $scope): string + private function compile(string $codes, string $attribute, string $labels, string $locale = 'null', string $scope = 'null'): string { return << \$linkedData, ], ]; - )() + })() PHP; } /** * @return array> */ - private function evaluate(array $context, array $codes, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, array $codes, string $attribute, array $labels, string|null $locale = null, string|null $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntitySimpleOption.php b/src/WithReferenceEntitySimpleOption.php index 62cb37a..6c34a1a 100644 --- a/src/WithReferenceEntitySimpleOption.php +++ b/src/WithReferenceEntitySimpleOption.php @@ -32,7 +32,7 @@ private function compile(string $code, string $locale = 'null', string $channel PHP; } - private function evaluate(array $context, string $code, ?string $locale = null, ?string $channel = null): array + private function evaluate(array $context, string $code, string|null $locale = null, string|null $channel = null): array { return [[ 'locale' => $locale, diff --git a/src/WithReferenceEntityValue.php b/src/WithReferenceEntityValue.php index 86f1f7c..ef56e6c 100644 --- a/src/WithReferenceEntityValue.php +++ b/src/WithReferenceEntityValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $channel return sprintf('([["data" => (%s), "locale" => (%s), "channel" => (%s)]])', $value, $locale, $channel); } - private function evaluate(array $context, string $value, ?string $locale = null, ?string $channel = null): array + private function evaluate(array $context, string $value, string|null $locale = null, string|null $channel = null): array { return [[ 'locale' => $locale, diff --git a/src/WithSimpleOption.php b/src/WithSimpleOption.php index 35b37b0..d18e4ce 100644 --- a/src/WithSimpleOption.php +++ b/src/WithSimpleOption.php @@ -38,7 +38,7 @@ private function compile(string $code, string $attribute, string $labels, string /** * @return array|string|null>> */ - private function evaluate(array $context, string $code, string $attribute, array $labels, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $code, string $attribute, array $labels, string|null $locale = null, string|null $scope = null): array { return [[ 'locale' => $locale, diff --git a/src/WithValue.php b/src/WithValue.php index 0f34b39..1b5a1d7 100644 --- a/src/WithValue.php +++ b/src/WithValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $scope = return sprintf('([["data" => (%s), "locale" => (%s), "scope" => (%s)]])', $value, $locale, $scope); } - private function evaluate(array $context, string $value, ?string $locale = null, ?string $scope = null): array + private function evaluate(array $context, string $value, string|null $locale = null, string|null $scope = null): array { return [[ 'locale' => $locale, From 0e2bd505d1a9d16fc557584767a6019def8e467e Mon Sep 17 00:00:00 2001 From: sebprt Date: Fri, 23 Jun 2023 11:21:07 +0200 Subject: [PATCH 08/10] Removed not necessary rule in php-cs-fixer --- .php-cs-fixer.dist.php | 1 - 1 file changed, 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 798a78e..17eb868 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -35,7 +35,6 @@ 'error_suppression' => true, 'ereg_to_preg' => true, 'dir_constant' => true, - 'nullable_type_declaration_for_default_null_value' => true, ]) ->setFinder($finder) ->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line From 35933a4f399fde9cc3e749c291a5ecef31481f68 Mon Sep 17 00:00:00 2001 From: sebprt Date: Fri, 23 Jun 2023 11:28:14 +0200 Subject: [PATCH 09/10] Reverted wrong changes --- src/DateTime.php | 2 +- src/DateTimeZone.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DateTime.php b/src/DateTime.php index b4f6907..67220c9 100644 --- a/src/DateTime.php +++ b/src/DateTime.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $format = 'null'): string + private function compile(string $date, string|null $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone("UTC"))', $date); diff --git a/src/DateTimeZone.php b/src/DateTimeZone.php index b0a9c2d..9d0392c 100644 --- a/src/DateTimeZone.php +++ b/src/DateTimeZone.php @@ -17,7 +17,7 @@ public function __construct($name) ); } - private function compile(string $date, string $zone, string $format = 'null'): string + private function compile(string $date, string $zone, string|null $format = null): string { if (null === $format) { return sprintf('new \DateTimeImmutable(%s, new \DateTimeZone(%s))', $date, $zone); From 7f79a66dd84e1d18b3d9c26e61d8bbfe9fbe5662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20PLANCHAT?= Date: Fri, 23 Jun 2023 11:37:22 +0200 Subject: [PATCH 10/10] Apply suggestions from code review --- src/WithSimpleOption.php | 2 +- src/WithValue.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WithSimpleOption.php b/src/WithSimpleOption.php index d18e4ce..9ee9a67 100644 --- a/src/WithSimpleOption.php +++ b/src/WithSimpleOption.php @@ -38,7 +38,7 @@ private function compile(string $code, string $attribute, string $labels, string /** * @return array|string|null>> */ - private function evaluate(array $context, string $code, string $attribute, array $labels, string|null $locale = null, string|null $scope = null): array + private function evaluate(array $context, string $code, string $attribute, array $labels, string $locale = 'null', string $scope = 'null'): array { return [[ 'locale' => $locale, diff --git a/src/WithValue.php b/src/WithValue.php index 1b5a1d7..d30457e 100644 --- a/src/WithValue.php +++ b/src/WithValue.php @@ -22,7 +22,7 @@ private function compile(string $value, string $locale = 'null', string $scope = return sprintf('([["data" => (%s), "locale" => (%s), "scope" => (%s)]])', $value, $locale, $scope); } - private function evaluate(array $context, string $value, string|null $locale = null, string|null $scope = null): array + private function evaluate(array $context, string $value, string $locale = 'null', string $scope = 'null'): array { return [[ 'locale' => $locale,