From 13894db474c6a6a38927a56a158526cee029f8b0 Mon Sep 17 00:00:00 2001 From: Ilario Pierbattista Date: Fri, 10 Nov 2023 19:10:34 +0100 Subject: [PATCH] fix cs --- src/Decoders.php | 14 ++- src/Internal/Combinators/LiteralDecoder.php | 2 +- src/Internal/Combinators/MapDecoder.php | 3 - src/Internal/FunctionUtils.php | 4 +- src/Reporters/PathReporter.php | 2 - src/Reporters/SimplePathReporter.php | 2 +- src/Utils/ConcreteDecoder.php | 3 - src/Validation/ListOfValidation.php | 4 +- .../DecodeApiResponseTest.php | 92 +++++++++---------- tests/examples/ParseCsv/ParseCsvTest.php | 10 +- .../Combinators/ArrayPropsDecoderTest.php | 3 +- tests/type-assertions/TypeAssertion.php | 20 +--- tests/unit/Reporters/Models/A.php | 3 +- tests/unit/Reporters/Models/SampleClass.php | 3 +- tests/unit/Reporters/ReportersTest.php | 35 +------ 15 files changed, 74 insertions(+), 126 deletions(-) diff --git a/src/Decoders.php b/src/Decoders.php index 76c84cd..cfebbfd 100644 --- a/src/Decoders.php +++ b/src/Decoders.php @@ -30,9 +30,7 @@ final class Decoders { - private function __construct() - { - } + private function __construct() {} /** * @template I @@ -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. @@ -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/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..3553997 100644 --- a/src/Internal/FunctionUtils.php +++ b/src/Internal/FunctionUtils.php @@ -71,8 +71,6 @@ public static function destructureIn(callable $f): callable /** * @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..36ba6a5 100644 --- a/src/Reporters/PathReporter.php +++ b/src/Reporters/PathReporter.php @@ -21,8 +21,6 @@ public static function create(): self } /** - * @param Validation $validation - * * @psalm-return list */ public function report(Validation $validation): array diff --git a/src/Reporters/SimplePathReporter.php b/src/Reporters/SimplePathReporter.php index 859807c..05ef6d7 100644 --- a/src/Reporters/SimplePathReporter.php +++ b/src/Reporters/SimplePathReporter.php @@ -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..9184499 100644 --- a/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php +++ b/tests/examples/DecodeApiResponse/DecodeApiResponseTest.php @@ -54,51 +54,51 @@ public function testJsonDecoding(): void private static function weatherJson(): string { - return <<> $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/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..e58de9b 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 */ @@ -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 */ @@ -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 */