Skip to content

Commit

Permalink
Upgrade PHPUnit and change coverage config (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario-pierbattista authored Apr 24, 2023
1 parent 7196242 commit 28318ae
Show file tree
Hide file tree
Showing 36 changed files with 120 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Run tests
run: ./vendor/bin/phpunit --coverage-clover=build/coverage-report.xml
run: ./vendor/bin/phpunit
- name: Upload code coverage
uses: codecov/codecov-action@v1
with:
file: build/coverage-report.xml
file: build/clover.xml
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type-assertions:
./vendor/bin/psalm tests/type-assertions --no-cache

test:
./vendor/bin/phpunit
XDEBUG_MODE=coverage ./vendor/bin/phpunit

.PHONY: ci ci-check cs-check cs-fix
cs-fix:
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"description": "A partial porting of io-ts in PHP",
"type": "library",
"require-dev": {
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9",
"giorgiosironi/eris": "^0.14.0",
"phpunit/php-code-coverage": "^7.0",
"phpat/phpat": "^0.10",
"facile-it/facile-coding-standard": "^0.5.1",
"facile-it/facile-coding-standard": "0.5.2",
"vimeo/psalm": "4.30.0",
"friendsofphp/php-cs-fixer": "^3.3",
"friendsofphp/php-cs-fixer": "3.16.0",
"phpstan/phpstan": "^1.8",
"rector/rector": "^0.15.25"
},
Expand Down
40 changes: 17 additions & 23 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/unit/</directory>
</testsuite>
<testsuite name="Examples">
<directory suffix="Test.php">./tests/examples</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" forceCoversAnnotation="false" beStrictAboutCoversAnnotation="false" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/unit/</directory>
</testsuite>
<testsuite name="Examples">
<directory suffix="Test.php">./tests/examples</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 2 additions & 0 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface Decoder
/**
* @psalm-param I $i
* @psalm-param Context $context
*
* @psalm-return Validation<A>
*
* @param mixed $i
Expand All @@ -24,6 +25,7 @@ public function validate($i, Context $context): Validation;

/**
* @psalm-param I $i
*
* @psalm-return Validation<A>
*
* @param mixed $i
Expand Down
14 changes: 14 additions & 0 deletions src/Decoders.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ private function __construct()
/**
* @template I
* @template A
*
* @psalm-param callable(I, Context):Validation<A> $f
* @psalm-param string $name
*
* @psalm-return Decoder<I, A>
*/
public static function make(callable $f, string $name = 'anon'): Decoder
Expand All @@ -51,8 +53,10 @@ public static function make(callable $f, string $name = 'anon'): Decoder
* @template IB
* @template A of IB
* @template B
*
* @psalm-param Decoder<IB, B> $db
* @psalm-param Decoder<IA, A> $da
*
* @psalm-return Decoder<IA, B>
*/
public static function compose(Decoder $db, Decoder $da): Decoder
Expand Down Expand Up @@ -161,6 +165,7 @@ public static function union(Decoder $a, Decoder $b, ?Decoder $c = null, ?Decode
*
* @psalm-param Decoder<IA, A> $a
* @psalm-param Decoder<IB, B> $b
*
* @psalm-return Decoder<IA & IB, A & B>
*/
public static function intersection(Decoder $a, Decoder $b): Decoder
Expand All @@ -180,8 +185,10 @@ public static function intersection(Decoder $a, Decoder $b): Decoder
* @template I
* @template A
* @template B
*
* @psalm-param callable(A):B $f
* @psalm-param Decoder<I, A> $da
*
* @psalm-return Decoder<I, B>
*/
public static function transformValidationSuccess(callable $f, Decoder $da): Decoder
Expand All @@ -194,7 +201,9 @@ public static function transformValidationSuccess(callable $f, Decoder $da): Dec

/**
* @psalm-template T of bool | string | int
*
* @psalm-param T $l
*
* @psalm-return Decoder<mixed, T>
*
* @param mixed $l
Expand All @@ -221,6 +230,7 @@ public static function listOf(Decoder $elementDecoder): Decoder
* @psalm-template MapOfDecoders of non-empty-array<array-key, Decoder<mixed, mixed>>
*
* @psalm-param MapOfDecoders $props
*
* @psalm-return Decoder<mixed, non-empty-array<array-key, mixed>>
*
* @param Decoder[] $props
Expand All @@ -244,6 +254,7 @@ public static function arrayProps(array $props): Decoder
* @psalm-param Decoder<mixed, Properties> $propsDecoder
* @psalm-param ClassFactory $factory
* @psalm-param string $decoderName
*
* @psalm-return Decoder<mixed, T>
*/
public static function classFromArrayPropsDecoder(
Expand Down Expand Up @@ -271,7 +282,9 @@ public static function classFromArrayPropsDecoder(

/**
* @psalm-template U
*
* @psalm-param U $default
*
* @psalm-return Decoder<mixed, U>
*
* @param null|mixed $default
Expand Down Expand Up @@ -369,6 +382,7 @@ public static function regex(string $regex): Decoder

/**
* @psalm-param string $regex
*
* @psalm-return Decoder<string, string>
*/
public static function stringMatchingRegex(string $regex): Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Arrays/ListOfDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* @psalm-template I of mixed
* @psalm-template IT of mixed
* @psalm-template T
*
* @template-implements Decoder<I, list<T>>
*
* @psalm-internal Facile\PhpCodec
*/
final class ListOfDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Combinators/ArrayPropsDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* @psalm-template Vs
* @psalm-template I
* @psalm-template PD of non-empty-array<K, Decoder<mixed, Vs>>
*
* @template-implements Decoder<I, non-empty-array<K, Vs>>
*
* @psalm-internal Facile\PhpCodec
*/
final class ArrayPropsDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Combinators/ComposeDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @psalm-template B
*
* @template-implements Decoder<IA, B>
*
* @psalm-internal Facile\PhpCodec
*/
final class ComposeDecoder implements Decoder
Expand All @@ -39,6 +40,7 @@ public function __construct(
/**
* @psalm-param IA $i
* @psalm-param Context $context
*
* @psalm-return Validation<B>
*
* @param mixed $i
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/Combinators/IntersectionDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* @psalm-template IB
* @psalm-template A
* @psalm-template B
*
* @template-implements Decoder<IA & IB, A & B>
*
* @psalm-internal Facile\PhpCodec
*/
final class IntersectionDecoder implements Decoder
Expand Down Expand Up @@ -89,8 +91,10 @@ public function getName(): string
/**
* @template T1
* @template T2
*
* @psalm-param T1 $a
* @psalm-param T2 $b
*
* @psalm-return T1&T2
*
* @param mixed $a
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/Combinators/LiteralDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@

/**
* @psalm-type literable = bool | string | int
*
* @template I of mixed
* @template T of literable
*
* @template-implements Decoder<I, T>
*
* @psalm-internal Facile\PhpCodec
*/
final class LiteralDecoder implements Decoder
{
/**
* @var T
*
* @readonly
*/
private $literal;
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Combinators/MapDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
/**
* @template A
* @template B
*
* @implements Decoder<A, B>
*
* @psalm-internal Facile\PhpCodec
*/
final class MapDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Combinators/UnionDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
* @psalm-template IB
* @psalm-template A
* @psalm-template B
*
* @template-implements Decoder<IA & IB, A | B>
*
* @psalm-internal Facile\PhpCodec
*/
final class UnionDecoder implements Decoder
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/FunctionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public static function nameFromProps(array $props): string
/**
* @psalm-template A
* @psalm-template I
*
* @psalm-param Decoder<I, A> $decoder
* @psalm-param I $input
*
* @psalm-return Validation<A>
*
* @param mixed $input
Expand All @@ -57,7 +59,9 @@ public static function standardDecode(Decoder $decoder, $input): Validation

/**
* @psalm-template R
*
* @psalm-param callable(mixed...):R $f
*
* @psalm-return callable(list<mixed>):R
*/
public static function destructureIn(callable $f): callable
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/BoolDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, bool>
*
* @psalm-internal Facile\PhpCodec
*/
final class BoolDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/CallableDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, callable>
*
* @psalm-internal Facile\PhpCodec
*/
final class CallableDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/FloatDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, float>
*
* @psalm-internal Facile\PhpCodec
*/
final class FloatDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/IntDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, int>
*
* @psalm-internal Facile\PhpCodec
*/
final class IntDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/MixedDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @psalm-template U of mixed
*
* @template-implements Decoder<U, U>
*
* @psalm-internal Facile\PhpCodec
*/
final class MixedDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/NullDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, null>
*
* @psalm-internal Facile\PhpCodec
*/
final class NullDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/StringDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

/**
* @template I of mixed
*
* @template-implements Decoder<I, string>
*
* @psalm-internal Facile\PhpCodec
*/
final class StringDecoder implements Decoder
Expand Down
2 changes: 2 additions & 0 deletions src/Internal/Primitives/UndefinedDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

/**
* @psalm-template U
*
* @template-implements Decoder<mixed, U>
*
* @psalm-internal Facile\PhpCodec
*/
final class UndefinedDecoder implements Decoder
Expand Down
1 change: 1 addition & 0 deletions src/Internal/Useful/DateTimeFromStringDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @template-implements Decoder<string, \DateTimeInterface>
*
* @psalm-internal Facile\PhpCodec
*/
final class DateTimeFromStringDecoder implements Decoder
Expand Down
1 change: 1 addition & 0 deletions src/Internal/Useful/IntFromStringDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @implements Decoder<string, int>
*
* @psalm-internal Facile\PhpCodec
*/
final class IntFromStringDecoder implements Decoder
Expand Down
Loading

0 comments on commit 28318ae

Please sign in to comment.