Skip to content

Commit cd239ac

Browse files
committed
[TASK] Use Rector 2.0
1 parent 5c01876 commit cd239ac

File tree

15 files changed

+50
-34
lines changed

15 files changed

+50
-34
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"helmich/typo3-typoscript-parser": "^2.6",
2020
"nette/utils": "^4.0",
2121
"ondram/ci-detector": "^4.2",
22-
"phpstan/phpstan": "^1.10.9",
22+
"phpstan/phpstan": "^2.0.0",
2323
"sebastian/diff": "^4.0 || ^5.0 || ^6.0",
2424
"simonschaufi/pretty-xml": "^3.0.0",
2525
"symfony/config": "^5.4 || ^6.4 || ^7.0",
@@ -34,9 +34,9 @@
3434
"require-dev": {
3535
"composer/composer": "^2.7",
3636
"ergebnis/composer-normalize": "^2.42",
37-
"phpstan/phpstan-phpunit": "^1.3",
37+
"phpstan/phpstan-phpunit": "^2.0.0",
3838
"phpunit/phpunit": "^10.5",
39-
"rector/rector": "^1.2.6",
39+
"rector/rector": "^2.0.0",
4040
"symplify/easy-coding-standard": "^12.3",
4141
"symplify/monorepo-builder": "^11.2",
4242
"symplify/rule-doc-generator": "12.1.3"

packages/fractor-phpstan-rules/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"require": {
1717
"php": "^8.2",
1818
"a9f/fractor": "^0.5",
19-
"phpstan/phpstan": "^1.10.9"
19+
"phpstan/phpstan": "^2.0.0"
2020
},
2121
"minimum-stability": "dev",
2222
"prefer-stable": true,

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

Lines changed: 11 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use a9f\Fractor\Caching\Detector\ChangedFilesDetector;
1010
use a9f\Fractor\Exception\ShouldNotHappenException;
1111
use a9f\Fractor\ValueObject\Indent;
12+
use a9f\FractorXml\Contract\DomNodeVisitor;
1213
use a9f\FractorXml\Contract\Formatter;
1314
use a9f\FractorXml\Contract\XmlFractor;
1415
use a9f\FractorXml\ValueObjectFactory\DomDocumentFactory;
@@ -35,6 +36,9 @@ public function canHandle(File $file): bool
3536
return $file->getFileExtension() === 'xml';
3637
}
3738

39+
/**
40+
* @param list<DomNodeVisitor> $appliedRules
41+
*/
3842
public function handle(File $file, iterable $appliedRules): void
3943
{
4044
$fileHasChanged = \false;

packages/fractor-xml/tests/DomDocumentIteratorTest.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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
{

0 commit comments

Comments
 (0)