Skip to content

Commit 04b0fe3

Browse files
committed
[TASK] Use Rector 2.0
1 parent 5527f57 commit 04b0fe3

File tree

12 files changed

+48
-22
lines changed

12 files changed

+48
-22
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"eta-orionis/composer-json-manipulator": "^1.0.1",
1919
"helmich/typo3-typoscript-parser": "^2.6",
2020
"nette/utils": "^4.0",
21-
"phpstan/phpstan": "^1.10.9",
21+
"phpstan/phpstan": "^1.10.9 || ^2.0.0",
2222
"sebastian/diff": "^4.0 || ^5.0 || ^6.0",
2323
"shanethehat/pretty-xml": "^1.0.2",
2424
"symfony/config": "^5.4 || ^6.4 || ^7.0",
@@ -33,9 +33,9 @@
3333
"require-dev": {
3434
"composer/composer": "^2.7",
3535
"ergebnis/composer-normalize": "^2.42",
36-
"phpstan/phpstan-phpunit": "^1.3",
36+
"phpstan/phpstan-phpunit": "^2.0.0",
3737
"phpunit/phpunit": "^10.5",
38-
"rector/rector": "^1.2.6",
38+
"rector/rector": "^2.0.0",
3939
"symplify/easy-coding-standard": "^12.3",
4040
"symplify/monorepo-builder": "^11.2",
4141
"symplify/rule-doc-generator": "12.1.3"

packages/fractor-phpstan-rules/src/Rules/AddChangelogDocBlockForFractorRule.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPStan\Analyser\Scope;
1414
use PHPStan\Reflection\ReflectionProvider;
1515
use PHPStan\Rules\Rule;
16+
use PHPStan\Rules\RuleErrorBuilder;
1617
use PHPStan\Type\FileTypeMapper;
1718

1819
/**
@@ -72,7 +73,11 @@ public function processNode(Node $node, Scope $scope): array
7273

7374
$docComment = $node->getDocComment();
7475
if (! $docComment instanceof Doc) {
75-
return [sprintf(self::ERROR_MESSAGE, $className)];
76+
return [
77+
RuleErrorBuilder::message(sprintf(self::ERROR_MESSAGE, $className))
78+
->identifier('change.docblock')
79+
->build(),
80+
];
7681
}
7782

7883
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
@@ -88,6 +93,10 @@ public function processNode(Node $node, Scope $scope): array
8893
return [];
8994
}
9095

91-
return [sprintf(self::ERROR_MESSAGE, $className)];
96+
return [
97+
RuleErrorBuilder::message(sprintf(self::ERROR_MESSAGE, $className))
98+
->identifier('change.docblock')
99+
->build(),
100+
];
92101
}
93102
}

packages/fractor-phpstan-rules/tests/Rules/AddChangelogDocBlockForFractorRule/AddChangelogDocBlockForFractorRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
final class AddChangelogDocBlockForFractorRuleTest extends RuleTestCase
1717
{
1818
/**
19-
* @param array<int, mixed> $expectedErrorsWithLines
19+
* @param list<array{0: string, 1: int, 2?: string|null}> $expectedErrorsWithLines
2020
*/
21-
#[DataProvider(methodName: 'provideData')]
21+
#[DataProvider('provideData')]
2222
public function testRule(string $filePath, array $expectedErrorsWithLines): void
2323
{
2424
$this->analyse([$filePath], $expectedErrorsWithLines);

packages/fractor-typoscript/src/Contract/TypoScriptNodeVisitor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
interface TypoScriptNodeVisitor
1414
{
1515
/**
16-
* @param list<Statement> $statements
16+
* @param Statement[] $statements
1717
*/
1818
public function beforeTraversal(File $file, array $statements): void;
1919

@@ -22,7 +22,7 @@ public function enterNode(Statement $node): Statement|int;
2222
public function leaveNode(Statement $node): void;
2323

2424
/**
25-
* @param list<Statement> $statements
25+
* @param Statement[] $statements
2626
*/
2727
public function afterTraversal(array $statements): void;
2828
}

packages/fractor-typoscript/src/TypoScriptStatementsIterator.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
public const REMOVE_NODE = 3;
2020

2121
/**
22-
* @var array<TypoScriptNodeVisitor>
22+
* @var TypoScriptNodeVisitor[]
2323
*/
2424
private iterable $visitors;
2525

2626
/**
27-
* @param list<TypoScriptNodeVisitor> $visitors
27+
* @param TypoScriptNodeVisitor[] $visitors
2828
*/
2929
public function __construct(iterable $visitors)
3030
{
@@ -34,8 +34,8 @@ public function __construct(iterable $visitors)
3434
}
3535

3636
/**
37-
* @param list<Statement> $statements
38-
* @return list<Statement>
37+
* @param Statement[] $statements
38+
* @return Statement[]
3939
*/
4040
public function traverseDocument(File $file, array $statements): array
4141
{
@@ -53,8 +53,8 @@ public function traverseDocument(File $file, array $statements): array
5353
}
5454

5555
/**
56-
* @param list<Statement> $statements
57-
* @return list<Statement>
56+
* @param Statement[] $statements
57+
* @return Statement[]
5858
*/
5959
private function processStatementList(array $statements): array
6060
{

packages/fractor-xml/src/XmlFileProcessor.php

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use a9f\Fractor\Application\ValueObject\File;
99
use a9f\Fractor\Exception\ShouldNotHappenException;
1010
use a9f\Fractor\ValueObject\Indent;
11+
use a9f\FractorXml\Contract\DomNodeVisitor;
1112
use a9f\FractorXml\Contract\Formatter;
1213
use a9f\FractorXml\Contract\XmlFractor;
1314
use a9f\FractorXml\ValueObjectFactory\DomDocumentFactory;
@@ -33,6 +34,9 @@ public function canHandle(File $file): bool
3334
return $file->getFileExtension() === 'xml';
3435
}
3536

37+
/**
38+
* @param list<DomNodeVisitor> $appliedRules
39+
*/
3640
public function handle(File $file, iterable $appliedRules): void
3741
{
3842
$document = $this->domDocumentFactory->create();

packages/fractor-xml/tests/DomDocumentIteratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private function getCollectingDomNodeVisitor(): CollectingDomNodeVisitor
217217
}
218218

219219
/**
220-
* @param list<string> $recorder
220+
* @param list<non-empty-string> $recorder
221221
*/
222222
private function getCallRecordingDomNodeVisitor(string $visitorName, array &$recorder): DomNodeVisitor
223223
{

packages/fractor/src/ChangesReporting/Output/ConsoleOutputFormatter.php

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ class ConsoleOutputFormatter implements OutputFormatterInterface
1717
*/
1818
public const NAME = 'console';
1919

20-
/**
21-
* @readonly
22-
*/
2320
private SymfonyStyle $symfonyStyle;
2421

2522
public function setSymfonyStyle(SymfonyStyle $symfonyStyle): void

packages/fractor/src/Configuration/AllowedFileExtensionsResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020
}
2121

2222
/**
23-
* @return list<non-empty-string>
23+
* @return array<int<0, max>, non-empty-string>
2424
*/
2525
public function resolve(): array
2626
{

packages/fractor/src/Configuration/ConfigurationFactory.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ public function __construct(
1919

2020
public function createFromInput(InputInterface $input): Configuration
2121
{
22+
/** @var list<non-empty-string> $paths */
23+
$paths = (array) $this->parameterBag->get(Option::PATHS);
24+
2225
return new Configuration(
2326
$this->allowedFileExtensionsResolver->resolve(),
24-
(array) $this->parameterBag->get(Option::PATHS),
27+
$paths,
2528
(array) $this->parameterBag->get(Option::SKIP),
2629
(bool) $input->getOption(Option::DRY_RUN),
2730
(bool) $input->getOption(Option::QUIET)
@@ -30,7 +33,7 @@ public function createFromInput(InputInterface $input): Configuration
3033

3134
/**
3235
* @api used in tests
33-
* @param string[] $paths
36+
* @param list<non-empty-string> $paths
3437
*/
3538
public function createForTests(array $paths): Configuration
3639
{

packages/fractor/src/Testing/PHPUnit/AbstractFractorTestCase.php

+9
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ private function bootContainer(): void
139139
);
140140
}
141141

142+
/**
143+
* @param non-empty-string $originalFilePath
144+
*/
142145
private function doTestFileMatchesExpectedContent(
143146
string $originalFilePath,
144147
string $expectedFileContents,
@@ -162,6 +165,9 @@ private function doTestFileMatchesExpectedContent(
162165
self::assertSame(trim($expectedFileContents), trim($changedContents), $failureMessage);
163166
}
164167

168+
/**
169+
* @param non-empty-string $filePath
170+
*/
165171
private function processFilePath(string $filePath): FractorTestResult
166172
{
167173
$configurationFactory = $this->getService(ConfigurationFactory::class);
@@ -175,6 +181,9 @@ private function processFilePath(string $filePath): FractorTestResult
175181
return new FractorTestResult($changedFileContents, $processResult);
176182
}
177183

184+
/**
185+
* @return non-empty-string
186+
*/
178187
private function createInputFilePath(string $fixtureFilePath): string
179188
{
180189
$inputFileDirectory = \dirname($fixtureFilePath);

phpstan.neon

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ parameters:
1616
- packages/**/tests/**/Fixture/*
1717
- packages/**/tests/Fixtures/*
1818
- packages/fractor-rule-generator/templates
19+
treatPhpDocTypesAsCertain: false
20+
ignoreErrors:
21+
- identifier: return.unusedType
22+
- identifier: varTag.nativeType

0 commit comments

Comments
 (0)