Skip to content

Commit bdf81f1

Browse files
committed
Raise Rector sets
1 parent ea39dba commit bdf81f1

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

rector.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
__DIR__ . '/tests',
1111
])
1212
// uncomment to reach your current PHP version
13-
// ->withPhpSets()
14-
->withTypeCoverageLevel(0)
15-
->withDeadCodeLevel(0)
16-
->withCodeQualityLevel(0)
17-
->withAttributesSets(phpunit: true)
13+
->withImportNames(importShortClasses: false)
14+
->withPhpSets()
15+
->withPreparedSets(
16+
deadCode: true,
17+
codeQuality: true,
18+
typeDeclarations: true
19+
)
20+
->withAttributesSets(all: true)
1821
->withSets([
1922
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
2023
])

src/AbstractTerminableCommand.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@ abstract class AbstractTerminableCommand extends Command implements SignalableCo
1313
{
1414
private const REQUEST_TO_TERMINATE = 143;
1515

16-
/** @var int */
17-
private $sleepDuration;
16+
private int $sleepDuration = 0;
1817

19-
/** @var bool */
20-
private $signalShutdownRequested;
21-
22-
public function __construct(?string $name = null)
23-
{
24-
$this->sleepDuration = 0;
25-
$this->signalShutdownRequested = false;
26-
27-
parent::__construct($name);
28-
}
18+
private bool $signalShutdownRequested = false;
2919

3020
final protected function execute(InputInterface $input, OutputInterface $output): int
3121
{
@@ -41,7 +31,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
4131

4232
$this->sleep($output);
4333

44-
/** @psalm-suppress DocblockTypeContradiction */
34+
/** @psalm-suppress TypeDoesNotContainType */
4535
if ($this->signalShutdownRequested) {
4636
$output->writeln('Signal received, terminating with exit code ' . self::REQUEST_TO_TERMINATE, OutputInterface::VERBOSITY_NORMAL);
4737

tests/E2E/TerminateCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Facile\TerminableLoop\Tests\E2E;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use PHPUnit\Framework\TestCase;
89
use Prophecy\PhpUnit\ProphecyTrait;
910
use Symfony\Component\Process\Process;
@@ -19,7 +20,7 @@ class TerminateCommandTest extends TestCase
1920
/**
2021
* @param string[] $commandLine
2122
*/
22-
#[\PHPUnit\Framework\Attributes\DataProvider('commandLineProvider')]
23+
#[DataProvider('commandLineProvider')]
2324
public function testStubCommand(array $commandLine): void
2425
{
2526
$process = new Process($commandLine);
@@ -57,7 +58,7 @@ public static function commandLineProvider(): array
5758
];
5859
}
5960

60-
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
61+
#[DataProvider('provideSignals')]
6162
public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
6263
{
6364
$process = new Process([
@@ -84,7 +85,7 @@ public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
8485
$this->assertSame($exitCode, $process->getExitCode());
8586
}
8687

87-
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
88+
#[DataProvider('provideSignals')]
8889
public function testSigTermDuringSleep(int $signal, int $exitCode): void
8990
{
9091
$process = new Process([

tests/Stub/StubTerminableCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
2828
$stubDuration = $this->getOption($input, 'stub');
2929
$sleepDuration = $this->getOption($input, 'sleep');
3030

31-
if ($stubDuration) {
31+
if ($stubDuration !== 0) {
3232
$process = new Process(['sleep', $stubDuration]);
3333
$process->run();
3434
}

tests/Unit/AbstractTerminableCommandTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Facile\TerminableLoop\Tests\Unit;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use Facile\TerminableLoop\AbstractTerminableCommand;
89
use PHPUnit\Framework\TestCase;
910
use Prophecy\Argument;
@@ -78,17 +79,13 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
7879
$stubCommand->run(new ArrayInput([]), $output->reveal());
7980
}
8081

81-
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
82+
#[DataProvider('signalProvider')]
8283
public function testReceiveSignalDuringCommandBody(int $signal): void
8384
{
8485
$stubCommand = new class ($signal) extends AbstractTerminableCommand {
85-
/** @var int */
86-
private $signal;
87-
88-
public function __construct(int $signal)
86+
public function __construct(private readonly int $signal)
8987
{
9088
parent::__construct('dummy:command');
91-
$this->signal = $signal;
9289
}
9390

9491
protected function commandBody(InputInterface $input, OutputInterface $output): int
@@ -110,7 +107,7 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
110107
$this->assertSame(143, $exitCode);
111108
}
112109

113-
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
110+
#[DataProvider('signalProvider')]
114111
public function testReceiveSignalBeforeCommandBody(int $signal): void
115112
{
116113
$stubCommand = $this->createStubTerminableCommand();
@@ -129,7 +126,7 @@ public function testReceiveSignalBeforeCommandBody(int $signal): void
129126
$this->assertSame(143, $exitCode);
130127
}
131128

132-
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
129+
#[DataProvider('signalProvider')]
133130
public function testGetSubscribedSignals(int $signal): void
134131
{
135132
$stubCommand = $this->createStubTerminableCommand();

0 commit comments

Comments
 (0)