Skip to content

Commit

Permalink
Merge pull request #10 from LeoVie/php-81-compatibility
Browse files Browse the repository at this point in the history
Add support for PHP 8.1
  • Loading branch information
LeoVie authored Apr 27, 2023
2 parents 55aaf4b + 19ccd94 commit 0d4657c
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ jobs:
php-version: [ '8.2' ]
coverage-driver: [ xdebug ]
include:
- { operating-system: 'ubuntu-20.04', php-version: '8.1', coverage-driver: 'xdebug'}
- { operating-system: 'ubuntu-20.04', php-version: '8.2', coverage-driver: 'xdebug'}
- { operating-system: 'windows-2022', php-version: '8.1', coverage-driver: 'xdebug'}
- { operating-system: 'windows-2022', php-version: '8.2', coverage-driver: 'xdebug'}
- { operating-system: 'macos-12', php-version: '8.1', coverage-driver: 'xdebug'}
- { operating-system: 'macos-12', php-version: '8.2', coverage-driver: 'xdebug'}

name: CI on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/console": "^6.2",
"symfony/css-selector": "^6.2",
"symfony/dom-crawler": "^6.2",
Expand Down
27 changes: 18 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" backupGlobals="false" colors="true"
executionOrder="random" resolveDependencies="true" failOnRisky="true" failOnWarning="true"
beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="false"
colors="true"
executionOrder="random"
resolveDependencies="true"
failOnRisky="true"
failOnWarning="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Functional">
<directory>tests/Functional</directory>
Expand All @@ -13,19 +20,21 @@
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./build/coverage/coverage-html"/>
<xml outputDirectory="./build/coverage/coverage-xml"/>
<clover outputFile="./build/coverage/clover.xml"/>
</report>
<exclude>
<directory>src/Command</directory>
</exclude>
</coverage>
<logging>
<junit outputFile="./build/coverage/junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/Command</directory>
</exclude>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/DTO/Baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Leovie\PhpunitCrapCheck\DTO;

readonly class Baseline
class Baseline
{
public function __construct(
public CrapCheckResult $crapCheckResult
public readonly CrapCheckResult $crapCheckResult
)
{
}
Expand Down
10 changes: 5 additions & 5 deletions src/DTO/BaselineDiffersResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Leovie\PhpunitCrapCheck\DTO;

readonly class BaselineDiffersResult implements BaselineCompareResult
class BaselineDiffersResult implements BaselineCompareResult
{
/**
* @param array<Method> $methodsNotOccurringAnymore
Expand All @@ -13,10 +13,10 @@
* @param array<Method> $methodsGotLessCrappy
*/
public function __construct(
public array $methodsNotOccurringAnymore,
public array $methodsNewlyOccurring,
public array $methodsGotCrappier,
public array $methodsGotLessCrappy
public readonly array $methodsNotOccurringAnymore,
public readonly array $methodsNewlyOccurring,
public readonly array $methodsGotCrappier,
public readonly array $methodsGotLessCrappy
)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/BaselineEqualsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Leovie\PhpunitCrapCheck\DTO;

readonly class BaselineEqualsResult implements BaselineCompareResult
class BaselineEqualsResult implements BaselineCompareResult
{
}
8 changes: 4 additions & 4 deletions src/DTO/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Leovie\PhpunitCrapCheck\DTO;

readonly class Method
class Method
{
public function __construct(
public string $classFQN,
public string $name,
public int $crap,
public readonly string $classFQN,
public readonly string $name,
public readonly int $crap,
)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/DTO/NonEmptyCrapCheckResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Leovie\PhpunitCrapCheck\DTO;

readonly class NonEmptyCrapCheckResult implements CrapCheckResult
class NonEmptyCrapCheckResult implements CrapCheckResult
{
/** @param array<Method> $tooCrappyMethods */
public function __construct(
public array $tooCrappyMethods
public readonly array $tooCrappyMethods
)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/BaselineOutputGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Leovie\PhpunitCrapCheck\DTO\EmptyCrapCheckResult;
use Leovie\PhpunitCrapCheck\DTO\NonEmptyCrapCheckResult;

readonly class BaselineOutputGenerator implements BaselineOutputGeneratorInterface
class BaselineOutputGenerator implements BaselineOutputGeneratorInterface
{
public function generate(Baseline $baseline): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/BaselineParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* }
* >
*/
readonly class BaselineParser implements BaselineParserInterface
class BaselineParser implements BaselineParserInterface
{
public function parse(string $baselineContent): Baseline
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/CloverParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Leovie\PhpunitCrapCheck\DTO\Method;
use Symfony\Component\DomCrawler\Crawler;

readonly class CloverParser implements CloverParserInterface
class CloverParser implements CloverParserInterface
{
/** @return array<Method> */
public function parseMethods(string $cloverReportContent): array
Expand Down
2 changes: 1 addition & 1 deletion src/Service/BaselineCompareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Leovie\PhpunitCrapCheck\DTO\Method;
use Leovie\PhpunitCrapCheck\DTO\NonEmptyCrapCheckResult;

readonly class BaselineCompareService
class BaselineCompareService
{
private const COMPARE_RESULT_EQUAL = 0;
private const COMPARE_RESULT_SMALLER = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/Service/BaselineOutputService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Leovie\PhpunitCrapCheck\DTO\Baseline;
use Leovie\PhpunitCrapCheck\Generator\BaselineOutputGeneratorInterface;

readonly class BaselineOutputService
class BaselineOutputService
{
public function __construct(
private BaselineOutputGeneratorInterface $baselineOutputGenerator
private readonly BaselineOutputGeneratorInterface $baselineOutputGenerator
)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/Service/CrapCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use Leovie\PhpunitCrapCheck\DTO\Method;
use Leovie\PhpunitCrapCheck\Parser\CloverParserInterface;

readonly class CrapCheckService
class CrapCheckService
{
public function __construct(
private CloverParserInterface $cloverParser
private readonly CloverParserInterface $cloverParser
)
{
}
Expand Down

0 comments on commit 0d4657c

Please sign in to comment.