Skip to content

Commit

Permalink
Update facile-it/facile-coding-standard requirement from 0.5.3 to 1.0…
Browse files Browse the repository at this point in the history
….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](facile-it/facile-coding-standard@0.5.3...1.0.0)

---
updated-dependencies:
- dependency-name: facile-it/facile-coding-standard
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix cs

* update actions2

* update action

* update action

* cs-fix

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ilario Pierbattista <ilario.pierbattista@facile.it>
  • Loading branch information
dependabot[bot] and ilario-pierbattista authored Nov 10, 2023
1 parent e9d2bd5 commit 60ff6f7
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 153 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 8 additions & 10 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 @@ -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);
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 @@ -264,7 +262,7 @@ public static function classFromArrayPropsDecoder(
): Decoder {
/** @psalm-var Decoder<Properties, T> $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())
);

Expand All @@ -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/ComposeDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
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
8 changes: 3 additions & 5 deletions src/Internal/FunctionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
{
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
6 changes: 2 additions & 4 deletions src/Reporters/PathReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ public static function create(): self
}

/**
* @param Validation $validation
*
* @psalm-return list<string>
*/
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
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Reporters/SimplePathReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand All @@ -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
100 changes: 50 additions & 50 deletions tests/examples/DecodeApiResponse/DecodeApiResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
)
),
Expand All @@ -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
);

Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion tests/examples/DecodePartialPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test(): void
'foo' => 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
);

Expand Down
4 changes: 2 additions & 2 deletions tests/examples/DecoderForSumType/DecoderForSumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
)
);
Expand Down
Loading

0 comments on commit 60ff6f7

Please sign in to comment.