Skip to content

Commit

Permalink
Improves API
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Sep 5, 2024
1 parent a6ec515 commit 9d5d160
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 36 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"require": {
"php": "^8.2",
"nikic/php-parser": "^5.1.0",
"pestphp/pest-plugin": "^v3.0.0",
"pestphp/pest-plugin": "^3.0.0",
"psr/simple-cache": "^3.0.0"
},
"require-dev": {
"pestphp/pest": "^v3.0.0",
"pestphp/pest": "^3.0.0",
"pestphp/pest-dev-tools": "^3.0.0",
"pestphp/pest-plugin-type-coverage": "^3.0.0"
},
Expand Down
33 changes: 11 additions & 22 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
]);

$rectorConfig->importNames();

$rectorConfig->rules([
InlineConstructorDefaultToPropertyRector::class,
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::TYPE_DECLARATION,
]);

};
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
)
->withPhpSets();
4 changes: 2 additions & 2 deletions src/Boostrappers/BootPhpUnitSubscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @internal
*/
final class BootPhpUnitSubscribers implements Bootstrapper
final readonly class BootPhpUnitSubscribers implements Bootstrapper
{
/**
* The list of Subscribers.
Expand All @@ -35,7 +35,7 @@ final class BootPhpUnitSubscribers implements Bootstrapper
* Creates a new instance of the Boot Subscribers.
*/
public function __construct(
private readonly Container $container,
private Container $container,
) {}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Boostrappers/BootSubscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @internal
*/
final class BootSubscribers implements Bootstrapper
final readonly class BootSubscribers implements Bootstrapper
{
/**
* The list of Subscribers.
Expand All @@ -34,7 +34,7 @@ final class BootSubscribers implements Bootstrapper
* Creates a new instance of the Boot Subscribers.
*/
public function __construct(
private readonly Container $container,
private Container $container,
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Event/Events/Test/Outcome/Tested.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
class Tested implements Event
{
public function __construct(
public readonly MutationTest $test,
public MutationTest $test,
) {}
}
8 changes: 4 additions & 4 deletions src/Support/MutationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class MutationGenerator

private int $offset;

private Node $originalNode;
private Node $originalNode; // @phpstan-ignore-line

private ?Node $modifiedNode = null;
private ?Node $modifiedNode = null; // @phpstan-ignore-line

/**
* @param array<int, class-string<Mutator>> $mutators
Expand Down Expand Up @@ -87,11 +87,11 @@ public function generate(

$modifiedAst = $traverser->traverse($stmts);

if (! $this->hasMutated()) {
if (! $this->mutated) { // @phpstan-ignore-line
break;
}

$newMutations[] = Mutation::create(
$newMutations[] = Mutation::create( // @phpstan-ignore-line
file: $file,
mutator: $mutator,
originalNode: $this->originalNode,
Expand Down
2 changes: 1 addition & 1 deletion src/Tester/MutationTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private function runTestsInParallel(MutationSuite $mutationSuite, array $covered
continue;
}

usleep(1000);
usleep(1000); // @pest-arch-ignore-line
}

$processId = (int) array_key_first(array_filter($this->runningTests, fn (?MutationTest $process): bool => ! $process instanceof MutationTest));
Expand Down
1 change: 1 addition & 0 deletions tests/Arch.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

use Pest\Mutate\Contracts\Mutator;
use Pest\Mutate\Contracts\MutatorSet;
use Pest\Mutate\Mutators;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Support/Printers/DefaultPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
it('reports a escaped mutation in compact mode', function (): void {
$this->printer->compact();

$this->printer->reportEscapedMutation($this->mutationTest);
$this->printer->reportUntestedMutation($this->mutationTest);

expect($this->out->fetch())
->toBe('x');
});

it('reports a escaped mutation in normal mode', function (): void {
$this->printer->reportEscapedMutation($this->mutationTest);
$this->printer->reportUntestedMutation($this->mutationTest);

expect($this->out->fetch())
->toContain('', 'Line 4:', 'EqualToIdentical')
Expand Down

0 comments on commit 9d5d160

Please sign in to comment.