Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario-pierbattista committed Nov 10, 2023
1 parent 3a69c84 commit 13894db
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 126 deletions.
14 changes: 6 additions & 8 deletions src/Decoders.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

final class Decoders
{
private function __construct()
{
}
private function __construct() {}

/**
* @template I
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -274,11 +272,11 @@ public static function classFromArrayPropsDecoder(
);
}

############################################################
# ###########################################################
#
# Primitives
#
############################################################
# ###########################################################

/**
* @psalm-template U
Expand Down Expand Up @@ -350,11 +348,11 @@ public static function callable(): Decoder
return new CallableDecoder();
}

############################################################
# ###########################################################
#
# Useful decoders
#
############################################################
# ###########################################################

/**
* @psalm-return Decoder<string, int>
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Combinators/LiteralDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 0 additions & 3 deletions src/Internal/Combinators/MapDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand Down
4 changes: 1 addition & 3 deletions src/Internal/FunctionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public static function destructureIn(callable $f): callable

/**
* @param mixed $x
*
* @return string
*/
public static function strigify($x): string
{
Expand All @@ -81,7 +79,7 @@ public static function strigify($x): string
}

if (\is_string($x)) {
return "\"$x\"";
return "\"{$x}\"";
}

if (\is_array($x)) {
Expand Down
2 changes: 0 additions & 2 deletions src/Reporters/PathReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static function create(): self
}

/**
* @param Validation $validation
*
* @psalm-return list<string>
*/
public function report(Validation $validation): array
Expand Down
2 changes: 1 addition & 1 deletion src/Reporters/SimplePathReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
3 changes: 0 additions & 3 deletions src/Utils/ConcreteDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ final class ConcreteDecoder implements Decoder

/**
* @psalm-param callable(I, Context):Validation<A> $validate
*
* @param callable $validate
* @param string $name
*/
public function __construct(
callable $validate,
Expand Down
4 changes: 1 addition & 3 deletions src/Validation/ListOfValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

final class ListOfValidation
{
public function __construct()
{
}
public function __construct() {}

/**
* @psalm-template T
Expand Down
92 changes: 46 additions & 46 deletions tests/examples/DecodeApiResponse/DecodeApiResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,51 +54,51 @@ public function testJsonDecoding(): void

private static function weatherJson(): string
{
return <<<JSON
{
"coord": {
"lon": 13.6729,
"lat": 43.2027
},
"weather": [
{
"id": 804,
"main": "Clouds",
"description": "overcast clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 286.82,
"feels_like": 286.01,
"temp_min": 285.93,
"temp_max": 288.15,
"pressure": 1015,
"humidity": 74
},
"visibility": 10000,
"wind": {
"speed": 0.89,
"deg": 270,
"gust": 0.89
},
"clouds": {
"all": 100
},
"dt": 1615564151,
"sys": {
"type": 3,
"id": 2001891,
"country": "IT",
"sunrise": "2021-03-12T06:22:48+01:00",
"sunset": "2021-03-12T18:07:28+01:00"
},
"timezone": 3600,
"id": 3172720,
"name": "Monte Urano",
"cod": 200
}
JSON;
return <<<'JSON'
{
"coord": {
"lon": 13.6729,
"lat": 43.2027
},
"weather": [
{
"id": 804,
"main": "Clouds",
"description": "overcast clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 286.82,
"feels_like": 286.01,
"temp_min": 285.93,
"temp_max": 288.15,
"pressure": 1015,
"humidity": 74
},
"visibility": 10000,
"wind": {
"speed": 0.89,
"deg": 270,
"gust": 0.89
},
"clouds": {
"all": 100
},
"dt": 1615564151,
"sys": {
"type": 3,
"id": 2001891,
"country": "IT",
"sunrise": "2021-03-12T06:22:48+01:00",
"sunset": "2021-03-12T18:07:28+01:00"
},
"timezone": 3600,
"id": 3172720,
"name": "Monte Urano",
"cod": 200
}
JSON;
}
}
10 changes: 5 additions & 5 deletions tests/examples/ParseCsv/ParseCsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class ParseCsvTest extends BaseTestCase
{
public function test(): void
{
$simpleCsv = <<<CSV
1,Milano,F205
2,Roma,H501
3,Monte Urano,F653
CSV;
$simpleCsv = <<<'CSV'
1,Milano,F205
2,Roma,H501
3,Monte Urano,F653
CSV;
$decoder = Decoders::listOf(
Decoders::pipe(
Decoders::string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public function test(): void
*
* @psalm-param Validation<non-empty-array<K, V>> $v
*/
$assert1 = function (Validation $v): void {
};
$assert1 = function (Validation $v): void {};

$assert1($v);
}
Expand Down
20 changes: 5 additions & 15 deletions tests/type-assertions/TypeAssertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
3 changes: 1 addition & 2 deletions tests/unit/Reporters/Models/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ public function __construct(
string $a,
int $b,
float $c
) {
}
) {}
}
3 changes: 1 addition & 2 deletions tests/unit/Reporters/Models/SampleClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ public function __construct(
int $number,
float $amount,
bool $flag
) {
}
) {}
}
35 changes: 5 additions & 30 deletions tests/unit/Reporters/ReportersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ class ReportersTest extends BaseTestCase
use TestTrait;

/**
* @param Reporter $reporter
* @param array $expected
*
* @return void
*
* @dataProvider provideReportRootErrors
*/
public function testReportRootError(
Expand Down Expand Up @@ -53,11 +48,7 @@ public function provideReportRootErrors(): array
}

/**
* @param Reporter $reporter
* @param mixed $value
* @param array $expected
*
* @return void
* @param mixed $value
*
* @dataProvider provideReportRootClassError
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -271,11 +258,7 @@ public function provideNestedArrayPropsReport(): array
}

/**
* @param Reporter $reporter
* @param mixed $value
* @param array $expected
*
* @return void
* @param mixed $value
*
* @dataProvider provideListOfClassReport
*/
Expand Down Expand Up @@ -364,11 +347,7 @@ public function provideListOfClassReport(): array
}

/**
* @param Reporter $reporter
* @param mixed $value
* @param array $expected
*
* @return void
* @param mixed $value
*
* @dataProvider provideUnionReport
*/
Expand Down Expand Up @@ -456,11 +435,7 @@ public function provideUnionReport(): array
}

/**
* @param Reporter $reporter
* @param mixed $value
* @param array $expected
*
* @return void
* @param mixed $value
*
* @dataProvider provideIntersectionReport
*/
Expand Down

0 comments on commit 13894db

Please sign in to comment.