Skip to content

Commit

Permalink
Update rector v0.15.20 (#3248)
Browse files Browse the repository at this point in the history
* TASK: Update Rector to version 0.15.20

* TASK: Add .inc suffix

* TASK: Add correct path

* TASK: Remove dead method call

* TASK: Fix incompleted tests

* TASK: Add .inc suffix for generator

* TASK: Fix phpstan errors

* TASK: Rectify
  • Loading branch information
sabbelasichon authored Mar 6, 2023
1 parent cf30be2 commit 0472e1b
Show file tree
Hide file tree
Showing 84 changed files with 183 additions and 274 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"nette/utils": "^3.0",
"nikic/php-parser": "^4.14",
"phpstan/phpstan": "^1.9.7",
"rector/rector": "0.15.10",
"rector/rector": "0.15.20",
"symfony/console": "^4.0 || ^5.0 || ^6.0",
"symfony/polyfill-php80": "^1.26",
"symfony/polyfill-php81": "^1.26",
Expand Down
1 change: 1 addition & 0 deletions src/NodeAnalyzer/SameClassMethodCallAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function haveSingleClass(array $chainMethodCalls): bool
$classOfClassMethod[] = null;
}
}

$uniqueClasses = \array_unique($classOfClassMethod);
return \count($uniqueClasses) < 2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rector/v10/v0/UseNativePhpHex2binMethodRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function refactor(Node $node): ?Node
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
'Turns \TYPO3\CMS\Extbase\Utility\TypeHandlingUtility::hex2bin calls to native php hex2bin',
'Turns ' . TypeHandlingUtility::class . '::hex2bin calls to native php hex2bin',
[
new CodeSample(
TypeHandlingUtility::class . '::hex2bin("6578616d706c65206865782064617461");',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Ssch\TYPO3Rector\Rector\v11\v0;

use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function __construct(NodesToAddCollector $nodesToAddCollector)
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
'Return TYPO3\CMS\Extbase\Http\ForwardResponse instead of TYPO3\CMS\Extbase\Mvc\Controller\ActionController::forward()',
'Return TYPO3\CMS\Extbase\Http\ForwardResponse instead of ' . ActionController::class . '::forward()',
[new CodeSample(
<<<'CODE_SAMPLE'
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
Expand Down
2 changes: 1 addition & 1 deletion src/Rector/v8/v6/AddTypeToColumnConfigRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function refactorColumn(Expr $columnName, Expr $columnTca): void
}
}

if (null === $config) {
if (!$config instanceof Array_) {
// found a column without a 'config' part. Create an empty 'config' array
$config = new Array_();
$columnTca->items[] = new ArrayItem($config, new String_('config'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private function refactorRichtextColumns(Array_ $columnItemsArray): void
$configurationArray = $configValue;
}

if (null === $configurationArray) {
if (!$configurationArray instanceof ArrayItem) {
$configurationArray = new ArrayItem(new Array_(), new String_('config'));
$columnItem->value->items[] = $configurationArray;
$this->hasAstBeenChanged = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function inferParam(Param $param): Type
if (! $functionLike instanceof FunctionLike) {
return new MixedType();
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$paramTagValueNodes = $phpDocInfo->getParamTagValueNodes();

Expand All @@ -73,6 +74,7 @@ public function inferParam(Param $param): Type
if ([] === $paramTypesByName) {
return new MixedType();
}

return $this->matchParamNodeFromDoc($paramTypesByName, $param);
}

Expand Down
8 changes: 6 additions & 2 deletions src/ValueObject/Indent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@

/**
* @see https://github.com/ergebnis/json-normalizer/blob/main/src/Format/Indent.php
* @see \Ssch\TYPO3Rector\Tests\ValueObject\IndentTest
*/
final class Indent
{
/**
* @var array<string, string>
*/
public const CHARACTERS = [
'space' => ' ',
'tab' => "\t",
Expand All @@ -26,7 +30,7 @@ private function __construct(string $value)

public static function fromFile(File $file): self
{
if (1 === \preg_match('/^(?P<indent>( +|\t+)).*/m', $file->getFileContent(), $match)) {
if (1 === \preg_match('#^(?P<indent>( +|\t+)).*#m', $file->getFileContent(), $match)) {
return self::fromString($match['indent']);
}

Expand All @@ -40,7 +44,7 @@ public function toString(): string

public function isSpace(): bool
{
return 1 === \preg_match('/^( +).*/', $this->value);
return 1 === \preg_match('#^( +).*#', $this->value);
}

public function length(): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.xml');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.xml.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.html.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function testSkip(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.txt');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.txt.inc');
}

/**
* @return Iterator<array<string>>
*/
public function provideDataSkippedFiles(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_other_extension/', '*.*');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_other_extension/', '*.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.txt');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.txt.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.gif');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/my_extension/', '*.gif.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
4 changes: 2 additions & 2 deletions tests/FileProcessor/TypoScript/TypoScriptProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test(string $filePath): void

public function testExtbasePersistence(): void
{
$news = new SmartFileInfo(__DIR__ . '/Fixture/Extbase/002_extbase_persistence.txt');
$news = new SmartFileInfo(__DIR__ . '/Fixture/Extbase/002_extbase_persistence.txt.inc');

$this->doTestFile($news->getRelativeFilePath());

Expand All @@ -44,6 +44,6 @@ public function provideConfigFilePath(): string
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/TypoScript', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture/TypoScript', '*.typoscript.inc');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.yaml');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.yaml.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.yaml');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.yaml.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ call_user_func(function ($extKey) {

use TICH\TichPinacoteca\Controller\MostraController;
use FriendsOfTYPO3\TtAddress\Controller\AddressController;
use Enw\TestsFixture\Controller\MessageController;
use Enw\Fixture\Controller\MessageController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use TYPO3\CMS\Form\Controller\FormFrontendController;

Expand Down Expand Up @@ -166,18 +166,18 @@ ExtensionUtility::configurePlugin(
call_user_func(
static function ($extensionKey) {
ExtensionUtility::configurePlugin(
'TestsFixture',
'Fixture',
'Formframework',
[\TYPO3\CMS\TestsFixture\Controller\FormFrontendController::class => 'render, perform'],
[\TYPO3\CMS\TestsFixture\Controller\FormFrontendController::class => 'perform'],
[\TYPO3\CMS\Fixture\Controller\FormFrontendController::class => 'render, perform'],
[\TYPO3\CMS\Fixture\Controller\FormFrontendController::class => 'perform'],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);
}, ('Form')
);

call_user_func(function ($extKey) {
ExtensionUtility::configurePlugin(
'TestsFixture',
'Fixture',
'Messages',
[
MessageController::class => 'list, show, ajaxReloadTeaserResults',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ final class RegisterExtbaseTypeConvertersAsServicesRectorTest extends AbstractRe
*/
public function test(string $filePath): void
{
$this->copyAdditionalFixturesToTemporaryDirectory();

$this->doTestFile($filePath);

$addedFilesWithContent = $this->removedAndAddedFilesCollector->getAddedFilesWithContent();
Expand Down Expand Up @@ -48,14 +46,4 @@ public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}

private function copyAdditionalFixturesToTemporaryDirectory(): void
{
$configurationDirectory = self::getFixtureTempDirectory() . '/Configuration/';
if (! file_exists($configurationDirectory)) {
mkdir(self::getFixtureTempDirectory() . '/Configuration/');
}

copy(__DIR__ . '/Fixture/Services.yaml', self::getFixtureTempDirectory() . '/Configuration/Services.yaml');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test(string $filePath): void
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.typoscript.inc');
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ final class ContentObjectRendererFileResourceRectorTest extends AbstractRectorTe
{
/**
* @dataProvider provideData()
* @return never
*/
public function test(string $filePath): void
{
$this->markTestIncomplete('The comparison is false positive wrongly.');
$this->doTestFile($filePath);
}

/**
Expand Down
Loading

0 comments on commit 0472e1b

Please sign in to comment.