From 60ff6f7f7d31bda0f706606b57dff85cc0f3256d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Nov 2023 19:30:49 +0100 Subject: [PATCH] Update facile-it/facile-coding-standard requirement from 0.5.3 to 1.0.0 (#95) * Update facile-it/facile-coding-standard requirement from 0.5.3 to 1.0.0 Updates the requirements on [facile-it/facile-coding-standard](https://github.com/facile-it/facile-coding-standard) to permit the latest version. - [Release notes](https://github.com/facile-it/facile-coding-standard/releases) - [Changelog](https://github.com/facile-it/facile-coding-standard/blob/1.x/CHANGELOG.md) - [Commits](https://github.com/facile-it/facile-coding-standard/compare/0.5.3...1.0.0) --- updated-dependencies: - dependency-name: facile-it/facile-coding-standard dependency-type: direct:development ... Signed-off-by: dependabot[bot] * fix cs * update actions2 * update action * update action * cs-fix --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ilario Pierbattista --- .github/workflows/ci.yaml | 4 +- .github/workflows/static-analysis.yaml | 4 +- composer.json | 2 +- src/Decoders.php | 18 ++-- src/Internal/Combinators/ComposeDecoder.php | 2 +- src/Internal/Combinators/LiteralDecoder.php | 2 +- src/Internal/Combinators/MapDecoder.php | 3 - src/Internal/FunctionUtils.php | 8 +- src/Reporters/PathReporter.php | 6 +- src/Reporters/SimplePathReporter.php | 6 +- src/Utils/ConcreteDecoder.php | 3 - src/Validation/ListOfValidation.php | 4 +- .../DecodeApiResponseTest.php | 100 +++++++++--------- .../examples/DecodePartialPropertiesTest.php | 2 +- .../DecoderForSumType/DecoderForSumType.php | 4 +- tests/examples/ParseCsv/ParseCsvTest.php | 12 +-- .../Combinators/ArrayPropsDecoderTest.php | 3 +- tests/type-assertions/TypeAssertion.php | 20 +--- tests/unit/DecodersTest.php | 2 +- .../Useful/StringMatchingRegexDecoderTest.php | 2 +- tests/unit/Reporters/Models/A.php | 3 +- tests/unit/Reporters/Models/SampleClass.php | 3 +- tests/unit/Reporters/ReportersTest.php | 41 ++----- 23 files changed, 101 insertions(+), 153 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 04b814b..313c2cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: php: [7.4, 8.0, 8.1] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -26,6 +26,6 @@ jobs: - name: Run tests run: ./vendor/bin/phpunit - name: Upload code coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: build/clover.xml diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index a4ea658..aa49540 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -26,11 +26,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: 7.4 - name: Install dependencies - uses: "ramsey/composer-install@v1" + uses: ramsey/composer-install@v2 - run: ${{ matrix.script }} diff --git a/composer.json b/composer.json index 2984375..ab818c6 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "phpunit/phpunit": "^9", "giorgiosironi/eris": "^0.14.0", "phpat/phpat": "^0.10", - "facile-it/facile-coding-standard": "0.5.3", + "facile-it/facile-coding-standard": "1.0.0", "vimeo/psalm": "4.30.0", "friendsofphp/php-cs-fixer": "3.38.0", "phpstan/phpstan": "^1.8", diff --git a/src/Decoders.php b/src/Decoders.php index 76c84cd..d0d41ca 100644 --- a/src/Decoders.php +++ b/src/Decoders.php @@ -30,9 +30,7 @@ final class Decoders { - private function __construct() - { - } + private function __construct() {} /** * @template I @@ -139,7 +137,7 @@ public static function union(Decoder $a, Decoder $b, ?Decoder $c = null, ?Decode $args = array_values( array_filter( func_get_args(), - static fn ($x): bool => $x instanceof Decoder + static fn($x): bool => $x instanceof Decoder ) ); $argc = count($args); @@ -177,7 +175,7 @@ public static function intersection(Decoder $a, Decoder $b): Decoder /** * This is structurally equivalent to a map function - * map :: (a -> b) -> Decoder a -> Decoder b + * map :: (a -> b) -> Decoder a -> Decoder b. * * I still don't know if decoders could be functors or something more complicated. * By now, let me introduce it with this strange name. I just need this feature. @@ -264,7 +262,7 @@ public static function classFromArrayPropsDecoder( ): Decoder { /** @psalm-var Decoder $mapDecoder */ $mapDecoder = new MapDecoder( - fn (array $props) => Internal\FunctionUtils::destructureIn($factory)(\array_values($props)), + fn(array $props) => Internal\FunctionUtils::destructureIn($factory)(\array_values($props)), \sprintf('%s(%s)', $decoderName, $propsDecoder->getName()) ); @@ -274,11 +272,11 @@ public static function classFromArrayPropsDecoder( ); } - ############################################################ + # ########################################################### # # Primitives # - ############################################################ + # ########################################################### /** * @psalm-template U @@ -350,11 +348,11 @@ public static function callable(): Decoder return new CallableDecoder(); } - ############################################################ + # ########################################################### # # Useful decoders # - ############################################################ + # ########################################################### /** * @psalm-return Decoder diff --git a/src/Internal/Combinators/ComposeDecoder.php b/src/Internal/Combinators/ComposeDecoder.php index f2503ee..06cfbde 100644 --- a/src/Internal/Combinators/ComposeDecoder.php +++ b/src/Internal/Combinators/ComposeDecoder.php @@ -53,7 +53,7 @@ public function validate($i, Context $context): Validation * * @param mixed $aValue */ - fn ($aValue): Validation => $this->db->validate($aValue, $context), + fn($aValue): Validation => $this->db->validate($aValue, $context), $this->da->validate($i, $context) ); } diff --git a/src/Internal/Combinators/LiteralDecoder.php b/src/Internal/Combinators/LiteralDecoder.php index 45a6dd0..0fe5d8b 100644 --- a/src/Internal/Combinators/LiteralDecoder.php +++ b/src/Internal/Combinators/LiteralDecoder.php @@ -65,7 +65,7 @@ public function getName(): string private static function literalName($x): string { if (\is_string($x)) { - return "'$x'"; + return "'{$x}'"; } if (\is_bool($x)) { diff --git a/src/Internal/Combinators/MapDecoder.php b/src/Internal/Combinators/MapDecoder.php index 7a3b710..33689c6 100644 --- a/src/Internal/Combinators/MapDecoder.php +++ b/src/Internal/Combinators/MapDecoder.php @@ -25,9 +25,6 @@ final class MapDecoder implements Decoder /** * @psalm-param callable(A):B $f - * - * @param callable $f - * @param string $name */ public function __construct(callable $f, string $name = 'map') { diff --git a/src/Internal/FunctionUtils.php b/src/Internal/FunctionUtils.php index f739a82..fb7d76c 100644 --- a/src/Internal/FunctionUtils.php +++ b/src/Internal/FunctionUtils.php @@ -23,7 +23,7 @@ public static function nameFromProps(array $props): string \implode( ', ', \array_map( - static fn (Decoder $t, $k): string => \sprintf( + static fn(Decoder $t, $k): string => \sprintf( '%s: %s', \is_string($k) ? $k : \sprintf('[%d]', $k), $t->getName() @@ -66,13 +66,11 @@ public static function standardDecode(Decoder $decoder, $input): Validation */ public static function destructureIn(callable $f): callable { - return fn (array $params) => $f(...$params); + return fn(array $params) => $f(...$params); } /** * @param mixed $x - * - * @return string */ public static function strigify($x): string { @@ -81,7 +79,7 @@ public static function strigify($x): string } if (\is_string($x)) { - return "\"$x\""; + return "\"{$x}\""; } if (\is_array($x)) { diff --git a/src/Reporters/PathReporter.php b/src/Reporters/PathReporter.php index 819c981..77d2059 100644 --- a/src/Reporters/PathReporter.php +++ b/src/Reporters/PathReporter.php @@ -21,18 +21,16 @@ public static function create(): self } /** - * @param Validation $validation - * * @psalm-return list */ public function report(Validation $validation): array { return Validation::fold( - fn (array $errors): array => \array_map( + fn(array $errors): array => \array_map( [self::class, 'getMessage'], $errors ), - fn (): array => ['No errors!'], + fn(): array => ['No errors!'], $validation ); } diff --git a/src/Reporters/SimplePathReporter.php b/src/Reporters/SimplePathReporter.php index 859807c..aa1dcf8 100644 --- a/src/Reporters/SimplePathReporter.php +++ b/src/Reporters/SimplePathReporter.php @@ -22,11 +22,11 @@ public static function create(): self public function report(Validation $validation): array { return Validation::fold( - static fn (array $errors): array => array_map( + static fn(array $errors): array => array_map( [self::class, 'getMessage'], $errors ), - static fn (): array => ['No errors'], + static fn(): array => ['No errors'], $validation ); } @@ -49,7 +49,7 @@ private static function getMessage(VError $error): string return sprintf( '%sInvalid value %s supplied to decoder "%s"', - empty($path) ? '' : "$path: ", + empty($path) ? '' : "{$path}: ", FunctionUtils::strigify($error->getValue()), $lastName ); diff --git a/src/Utils/ConcreteDecoder.php b/src/Utils/ConcreteDecoder.php index 982c132..d33a6e6 100644 --- a/src/Utils/ConcreteDecoder.php +++ b/src/Utils/ConcreteDecoder.php @@ -23,9 +23,6 @@ final class ConcreteDecoder implements Decoder /** * @psalm-param callable(I, Context):Validation $validate - * - * @param callable $validate - * @param string $name */ public function __construct( callable $validate, diff --git a/src/Validation/ListOfValidation.php b/src/Validation/ListOfValidation.php index 8a59eba..38bef12 100644 --- a/src/Validation/ListOfValidation.php +++ b/src/Validation/ListOfValidation.php @@ -6,9 +6,7 @@ final class ListOfValidation { - public function __construct() - { - } + public function __construct() {} /** * @psalm-template T diff --git a/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php b/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php index 8a20837..0f9ec5f 100644 --- a/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php +++ b/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php @@ -19,7 +19,7 @@ public function testJsonDecoding(): void 'lon' => Decoders::float(), 'lat' => Decoders::float(), ]), - fn (float $lon, float $lat): Coordinates => new Coordinates($lon, $lat), + fn(float $lon, float $lat): Coordinates => new Coordinates($lon, $lat), Coordinates::class ), 'weather' => Decoders::listOf( @@ -29,7 +29,7 @@ public function testJsonDecoding(): void 'main' => Decoders::string(), 'description' => Decoders::string(), ]), - fn (int $id, string $main, string $desc): Weather => new Weather($id, $main, $desc), + fn(int $id, string $main, string $desc): Weather => new Weather($id, $main, $desc), Weather::class ) ), @@ -39,11 +39,11 @@ public function testJsonDecoding(): void 'sunrise' => Decoders::dateTimeFromString(), 'sunset' => Decoders::dateTimeFromString(), ]), - fn (string $county, \DateTimeInterface $sunrise, \DateTimeInterface $sunset): Sys => new Sys($county, $sunrise, $sunset), + fn(string $county, \DateTimeInterface $sunrise, \DateTimeInterface $sunset): Sys => new Sys($county, $sunrise, $sunset), Sys::class ), ]), - fn (Coordinates $coordinates, array $weathers, Sys $sys): OpenWeatherResponse => new OpenWeatherResponse($coordinates, $weathers, $sys), + fn(Coordinates $coordinates, array $weathers, Sys $sys): OpenWeatherResponse => new OpenWeatherResponse($coordinates, $weathers, $sys), OpenWeatherResponse::class ); @@ -54,51 +54,51 @@ public function testJsonDecoding(): void private static function weatherJson(): string { - return << Decoders::string(), 'bar' => Decoders::union(Decoders::int(), Decoders::undefined(-1)), ]), - fn (string $foo, int $bar): DecodePartialPropertiesTest\A => new DecodePartialPropertiesTest\A($foo, $bar), + fn(string $foo, int $bar): DecodePartialPropertiesTest\A => new DecodePartialPropertiesTest\A($foo, $bar), DecodePartialPropertiesTest\A::class ); diff --git a/tests/examples/DecoderForSumType/DecoderForSumType.php b/tests/examples/DecoderForSumType/DecoderForSumType.php index 565f983..e7b3c9c 100644 --- a/tests/examples/DecoderForSumType/DecoderForSumType.php +++ b/tests/examples/DecoderForSumType/DecoderForSumType.php @@ -27,7 +27,7 @@ public function testSumTypes(): void 'propA' => Decoders::int(), 'propB' => Decoders::string(), ]), - fn (string $t, string $subT, int $propA, string $propB): A => new A($subT, $propA, $propB), + fn(string $t, string $subT, int $propA, string $propB): A => new A($subT, $propA, $propB), A::class ), Decoders::classFromArrayPropsDecoder( @@ -41,7 +41,7 @@ public function testSumTypes(): void 'amount' => Decoders::float(), 'flag' => Decoders::bool(), ]), - fn (string $t, int $case, float $amount, bool $flag): B => new B($case, $amount, $flag), + fn(string $t, int $case, float $amount, bool $flag): B => new B($case, $amount, $flag), B::class ) ); diff --git a/tests/examples/ParseCsv/ParseCsvTest.php b/tests/examples/ParseCsv/ParseCsvTest.php index 67d2565..407b83b 100644 --- a/tests/examples/ParseCsv/ParseCsvTest.php +++ b/tests/examples/ParseCsv/ParseCsvTest.php @@ -12,11 +12,11 @@ class ParseCsvTest extends BaseTestCase { public function test(): void { - $simpleCsv = << Decoders::string(), 'code' => Decoders::string(), ]), - static fn (int $id, string $name, string $code): City => new City($id, $name, $code), + static fn(int $id, string $name, string $code): City => new City($id, $name, $code), City::class ) ) diff --git a/tests/type-assertions/Internal/Combinators/ArrayPropsDecoderTest.php b/tests/type-assertions/Internal/Combinators/ArrayPropsDecoderTest.php index 65519d7..90cd32e 100644 --- a/tests/type-assertions/Internal/Combinators/ArrayPropsDecoderTest.php +++ b/tests/type-assertions/Internal/Combinators/ArrayPropsDecoderTest.php @@ -29,8 +29,7 @@ public function test(): void * * @psalm-param Validation> $v */ - $assert1 = function (Validation $v): void { - }; + $assert1 = function (Validation $v): void {}; $assert1($v); } diff --git a/tests/type-assertions/TypeAssertion.php b/tests/type-assertions/TypeAssertion.php index ffd40f9..ce17415 100644 --- a/tests/type-assertions/TypeAssertion.php +++ b/tests/type-assertions/TypeAssertion.php @@ -17,26 +17,16 @@ protected static function mixed() /** * @psalm-param true $b */ - protected static function assertTrue(bool $b): void - { - } + protected static function assertTrue(bool $b): void {} /** * @psalm-param false $b */ - protected static function assertFalse(bool $b): void - { - } + protected static function assertFalse(bool $b): void {} - protected static function assertBool(bool $b): void - { - } + protected static function assertBool(bool $b): void {} - protected static function assertString(string $s): void - { - } + protected static function assertString(string $s): void {} - protected static function assertInt(int $i): void - { - } + protected static function assertInt(int $i): void {} } diff --git a/tests/unit/DecodersTest.php b/tests/unit/DecodersTest.php index ec8502d..c288c8a 100644 --- a/tests/unit/DecodersTest.php +++ b/tests/unit/DecodersTest.php @@ -16,7 +16,7 @@ class DecodersTest extends BaseTestCase public function testMap(): void { $decoder = Decoders::transformValidationSuccess( - fn (int $v): DecodersTest\A => new DecodersTest\A($v), + fn(int $v): DecodersTest\A => new DecodersTest\A($v), Decoders::int() ); diff --git a/tests/unit/Internal/Useful/StringMatchingRegexDecoderTest.php b/tests/unit/Internal/Useful/StringMatchingRegexDecoderTest.php index 81e190b..711be21 100644 --- a/tests/unit/Internal/Useful/StringMatchingRegexDecoderTest.php +++ b/tests/unit/Internal/Useful/StringMatchingRegexDecoderTest.php @@ -28,7 +28,7 @@ public function testDecode(): void $this ->forAll( Generators::map( - fn (int $x): string => (string) $x, + fn(int $x): string => (string) $x, Generators::choose(10, 99999) ) ) diff --git a/tests/unit/Reporters/Models/A.php b/tests/unit/Reporters/Models/A.php index 0f76331..2f2fd37 100644 --- a/tests/unit/Reporters/Models/A.php +++ b/tests/unit/Reporters/Models/A.php @@ -10,6 +10,5 @@ public function __construct( string $a, int $b, float $c - ) { - } + ) {} } diff --git a/tests/unit/Reporters/Models/SampleClass.php b/tests/unit/Reporters/Models/SampleClass.php index 5719111..a51978e 100644 --- a/tests/unit/Reporters/Models/SampleClass.php +++ b/tests/unit/Reporters/Models/SampleClass.php @@ -11,6 +11,5 @@ public function __construct( int $number, float $amount, bool $flag - ) { - } + ) {} } diff --git a/tests/unit/Reporters/ReportersTest.php b/tests/unit/Reporters/ReportersTest.php index be65679..286b955 100644 --- a/tests/unit/Reporters/ReportersTest.php +++ b/tests/unit/Reporters/ReportersTest.php @@ -20,11 +20,6 @@ class ReportersTest extends BaseTestCase use TestTrait; /** - * @param Reporter $reporter - * @param array $expected - * - * @return void - * * @dataProvider provideReportRootErrors */ public function testReportRootError( @@ -53,11 +48,7 @@ public function provideReportRootErrors(): array } /** - * @param Reporter $reporter - * @param mixed $value - * @param array $expected - * - * @return void + * @param mixed $value * * @dataProvider provideReportRootClassError */ @@ -72,7 +63,7 @@ public function testReportRootClassError( 'b' => Decoders::int(), 'c' => Decoders::float(), ]), - static fn (string $a, int $b, float $c): Models\A => new Models\A($a, $b, $c), + static fn(string $a, int $b, float $c): Models\A => new Models\A($a, $b, $c), Models\A::class ); @@ -151,7 +142,7 @@ public function testReportClass(): void 'b' => Decoders::int(), 'c' => Decoders::float(), ]), - static fn (string $a, int $b, float $c): Models\A => new Models\A($a, $b, $c), + static fn(string $a, int $b, float $c): Models\A => new Models\A($a, $b, $c), Models\A::class ); @@ -195,11 +186,7 @@ function (array $value) use ($simplePathReporter, $pathReporter, $decoder): void } /** - * @param Reporter $reporter - * @param array $expected - * @param mixed $value - * - * @return void + * @param mixed $value * * @dataProvider provideNestedArrayPropsReport */ @@ -271,11 +258,7 @@ public function provideNestedArrayPropsReport(): array } /** - * @param Reporter $reporter - * @param mixed $value - * @param array $expected - * - * @return void + * @param mixed $value * * @dataProvider provideListOfClassReport */ @@ -289,7 +272,7 @@ public function testListOfClassReport(Reporter $reporter, $value, array $expecte 'amount' => Decoders::float(), 'flag' => Decoders::bool(), ]), - static fn (string $name, int $number, float $amount, bool $flag) => new SampleClass($name, $number, $amount, $flag), + static fn(string $name, int $number, float $amount, bool $flag) => new SampleClass($name, $number, $amount, $flag), 'SampleClass' ) ); @@ -364,11 +347,7 @@ public function provideListOfClassReport(): array } /** - * @param Reporter $reporter - * @param mixed $value - * @param array $expected - * - * @return void + * @param mixed $value * * @dataProvider provideUnionReport */ @@ -456,11 +435,7 @@ public function provideUnionReport(): array } /** - * @param Reporter $reporter - * @param mixed $value - * @param array $expected - * - * @return void + * @param mixed $value * * @dataProvider provideIntersectionReport */