Skip to content

Commit a737e86

Browse files
committed
Get ready for rector v2
1 parent 8db3dc5 commit a737e86

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

.phpcq.lock

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

.phpcq.yaml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ phpcq:
5050
- D2CCAC42F6295E7D
5151
# PHP_CodeSniffer
5252
- 5E6DDE998AB73B8E
53+
- A978220305CD5C32
5354
# Composer normalize
5455
- C00543248C87FB13
5556
# phpmd

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcq-plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ext-pcre": "*"
1111
},
1212
"composer": {
13-
"rector/rector": "^1.0"
13+
"rector/rector": "^1.0 || ^2.0"
1414
}
1515
}
1616
}

repository.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"rector": [
44
{
55
"api-version": "1.0.0",
6-
"version": "1.0.0",
6+
"version": "1.0.1",
77
"type": "php-file",
88
"url": "src/rector.php",
99
"requirements": {
@@ -13,12 +13,12 @@
1313
"ext-pcre": "*"
1414
},
1515
"composer": {
16-
"rector/rector": "^1.0"
16+
"rector/rector": "^1.0 || ^2.0"
1717
}
1818
},
1919
"checksum": {
2020
"type": "sha-512",
21-
"value": "c387c8001855475f410a816b5d361631ba4eba5a369323e7d3114f8d0ddbbf5b10e549c22d04ee2981729268816430ab6eaeb862d747881a8c279faddc346239"
21+
"value": "05ae79d94caa01dc604180e92ca3c03e92846e8fe009b311248c35f18644790ea898653dd1811137ee3ecd92f38836d63633e36b8ba6390a08d25e265f168a16"
2222
}
2323
}
2424
]

src/rector.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
return new class implements DiagnosticsPluginInterface, ExecPluginInterface
2222
{
23+
/** @psalm-suppress MissingClassConstType */
2324
private const RECTOR_FILE_TEMPLATE = <<<'PHP'
2425
<?php
2526
@@ -54,11 +55,13 @@
5455
})(%s, %s, %s, %s);
5556
PHP;
5657

58+
#[Override]
5759
public function getName(): string
5860
{
5961
return 'rector';
6062
}
6163

64+
#[Override]
6265
public function describeConfiguration(PluginConfigurationBuilderInterface $configOptionsBuilder): void
6366
{
6467
$configOptionsBuilder
@@ -75,6 +78,7 @@ public function describeConfiguration(PluginConfigurationBuilderInterface $confi
7578
->isRequired();
7679
}
7780

81+
#[Override]
7882
public function createDiagnosticTasks(
7983
PluginConfigurationInterface $config,
8084
EnvironmentInterface $environment,
@@ -91,6 +95,7 @@ public function createDiagnosticTasks(
9195
yield $factory->build();
9296
}
9397

98+
#[Override]
9499
public function describeExecTask(
95100
ExecTaskDefinitionBuilderInterface $definitionBuilder,
96101
EnvironmentInterface $environment,
@@ -165,11 +170,11 @@ private function parseOption(
165170

166171
foreach (array_filter([$matches[3], $matches[5]]) as $name) {
167172
$option = $builder->describeOption($name, $matches[8]);
168-
if ($matches[7]) {
173+
if ($matches[7] !== '' && $matches[7] !== '0') {
169174
$option->withOptionalValue($matches[7]);
170175
}
171176

172-
if ($matches[2]) {
177+
if ($matches[2] !== '' && $matches[2] !== '0') {
173178
$option->withShortcut($matches[2]);
174179
}
175180
}
@@ -221,6 +226,7 @@ private function parseCommand(
221226
}
222227

223228
/** {@inheritDoc} */
229+
#[Override]
224230
public function createExecTask(
225231
string|null $application,
226232
array $arguments,
@@ -282,6 +288,7 @@ public function __construct(private readonly bool $dryRun)
282288
{
283289
}
284290

291+
#[Override]
285292
public function createFor(TaskReportInterface $report): OutputTransformerInterface
286293
{
287294
/**
@@ -317,11 +324,13 @@ public function __construct(
317324
$this->data = BufferedLineReader::create();
318325
}
319326

327+
#[Override]
320328
public function write(string $data, int $channel): void
321329
{
322330
$this->data->push($data);
323331
}
324332

333+
#[Override]
325334
public function finish(int $exitCode): void
326335
{
327336
$this->process();
@@ -400,6 +409,7 @@ private function createOutputToStringHandler(): Stringable|OutputInterface
400409
return new class implements OutputInterface {
401410
private string $output = '';
402411

412+
#[Override]
403413
public function write(
404414
string $message,
405415
int $verbosity = self::VERBOSITY_NORMAL,
@@ -410,6 +420,7 @@ public function write(
410420
}
411421
}
412422

423+
#[Override]
413424
public function writeln(
414425
string $message,
415426
int $verbosity = self::VERBOSITY_NORMAL,

0 commit comments

Comments
 (0)