Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"nette/utils": "^3.2.10 || ^4.0.4",
"nikic/php-parser": "^5.7.0",
"phpstan/phpstan": "^2.1.34",
"rector/rector": "^2.3.7",
"rector/rector": "^2.4.1",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.4 || ^7.0",
"symfony/finder": "^5.4 || ^6.4 || ^7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private function shouldSkip(Variable $node): bool
return false;
}

if ($this->filesFinder->isExtLocalConf($this->file->getFilePath())) {
if ($this->filesFinder->isExtLocalConf($this->getFile()->getFilePath())) {
return false;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function refactor(Node $node)

$content = $this->betterStandardPrinter->prettyPrint([$staticMethodCall]) . ';';

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/sys_template.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, $content . PHP_EOL);
Expand Down Expand Up @@ -143,6 +143,6 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function refactor(Node $node)

$content = $this->betterStandardPrinter->prettyPrint([$staticMethodCall]) . ';';

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/' . $tableNameAsString . '.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, $content . PHP_EOL);
Expand Down Expand Up @@ -148,7 +148,7 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function refactor(Node $node)

$content = $this->betterStandardPrinter->prettyPrint([$staticMethodCall]) . ';';

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/tt_content.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, $content . PHP_EOL);
Expand Down Expand Up @@ -143,6 +143,6 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node

$extensionName = $this->valueResolver->getValue($extensionNameArgumentValue);

$fileInfo = $this->fileInfoFactory->createFileInfoFromPath($this->file->getFilePath());
$fileInfo = $this->fileInfoFactory->createFileInfoFromPath($this->getFile()->getFilePath());

if ($extensionNameArgumentValue instanceof Concat
&& $this->isPotentiallyUndefinedExtensionKeyVariable($extensionNameArgumentValue)
Expand Down
2 changes: 1 addition & 1 deletion rules/TYPO310/v1/RegisterPluginWithVendorNameRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function removeVendorNameIfNeeded(StaticCall $staticCall): ?Node

$extensionName = $this->valueResolver->getValue($extensionNameArgumentValue);

$fileInfo = $this->fileInfoFactory->createFileInfoFromPath($this->file->getFilePath());
$fileInfo = $this->fileInfoFactory->createFileInfoFromPath($this->getFile()->getFilePath());

if ($extensionNameArgumentValue instanceof Concat
&& $this->isPotentiallyUndefinedExtensionKeyVariable($extensionNameArgumentValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private function createIsCliCall(): StaticCall

private function shouldSkip(): bool
{
$filePath = $this->file->getFilePath();
$filePath = $this->getFile()->getFilePath();
if ($this->filesFinder->isExtLocalConf($filePath)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/TYPO311/v2/MigrateFrameModuleToSvgTreeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getRuleDefinition(): RuleDefinition
private function shouldSkip(Node $node): bool
{
if (! $this->filesFinder->isExtTables(
$this->file->getFilePath()
$this->getFile()->getFilePath()
) && ! StaticPHPUnitEnvironment::isPHPUnitRun()) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions rules/TYPO311/v4/RegisterIconToIconFileRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function refactor(Node $node): ?int

[$iconIdentifierString, $innerItems] = $this->createNewIconArray($methodCall);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$iconsFilePath = $directoryName . '/Configuration/Icons.php';

$newContent = $this->addNewIconToIconsFile($iconsFilePath, $iconIdentifierString, $innerItems);
Expand Down Expand Up @@ -195,7 +195,7 @@ private function shouldSkip(MethodCall $methodCall): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions rules/TYPO312/v0/MigrateBackendModuleRegistrationRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function refactor(Node $node): ?int

$content = ArrayUtility::arrayExport($returnArray);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/Backend/Modules.php';

if ($this->filesystem->fileExists($newConfigurationFile)) {
Expand Down Expand Up @@ -259,7 +259,7 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function refactor(Node $node)
continue;
}

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/' . $tableName . '.php';
$this->writeConfigurationToFile($newConfigurationFile, $tableName);
}
Expand All @@ -117,7 +117,7 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}

private function writeConfigurationToFile(string $newConfigurationFile, string $tableName): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function refactor(Node $node)

$this->resolvePotentialExtensionKeyByConcatenation($contentArgumentValue);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());

$content = $this->valueResolver->getValue($contentArgumentValue);
$newConfigurationFile = $directoryName . '/Configuration/page.tsconfig';
Expand Down Expand Up @@ -144,6 +144,6 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function refactor(Node $node)

$this->resolvePotentialExtensionKeyByConcatenation($contentArgumentValue);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());

$content = $this->valueResolver->getValue($contentArgumentValue);
$newConfigurationFile = $directoryName . '/Configuration/user.tsconfig';
Expand Down Expand Up @@ -144,6 +144,6 @@ private function shouldSkip(StaticCall $staticMethodCall): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if ($this->shouldSkip($this->file->getFilePath(), $node)) {
if ($this->shouldSkip($this->getFile()->getFilePath(), $node)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
Expand Down Expand Up @@ -118,7 +117,6 @@ public function refactor(Node $node): ?Node
return null;
}

/** @var Expr $originalColumnsOnlyValueNode */
$originalColumnsOnlyValueNode = $columnsOnlyItemNode->value;

$innerArrayItems = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ private function shouldSkip(MethodCall $methodCall): bool
{
// Ensure the call is on $this->view or a variable of the correct type
if ($methodCall->var instanceof PropertyFetch) {
/** @var PropertyFetch $propertyFetch */
$propertyFetch = $methodCall->var;
// Not $this->view, check if it's another variable of the correct type
if ((! $this->isName($propertyFetch->var, 'this') || ! $this->isName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public function refactor(Node $node): ?Node
}
}

$psr4 = $this->composerPsr4Resolver->resolve($this->file);
$psr4 = $this->composerPsr4Resolver->resolve($this->getFile());
if ($psr4 !== null) {
$filePath = $this->file->getFilePath();
$filePath = $this->getFile()->getFilePath();
$directoryName = $this->filesFinder->isInTCAOverridesFolder($filePath)
? dirname($filePath, 4)
: dirname($filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function refactor(Node $node): ?int

$content = $this->prettyTypo3Printer->prettyPrint($newNodes);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/sys_file_collection.php';

if ($this->filesystem->fileExists($newConfigurationFile)) {
Expand Down Expand Up @@ -223,6 +223,6 @@ private function shouldSkip(MethodCall $methodCall): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ public function refactor(Node $node): ?Node
$finalStmt = new Return_($replacementNode, [
AttributeKey::COMMENTS => $comments,
]);
} elseif (! $assignNode instanceof Assign) {
return null;
} else {
// Re-use the original variable for assignment
/** @var Assign $assignNode */
$uriAssign = new Assign($assignNode->var, $replacementNode);
$finalStmt = new Expression($uriAssign, [
AttributeKey::COMMENTS => $comments,
Expand Down
4 changes: 2 additions & 2 deletions rules/TYPO314/v0/MigrateIpAnonymizationTaskRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private function shouldSkip(Expression $node): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}

private function createNewAssignmentTarget(Expr $classConstFetch): ArrayDimFetch
Expand All @@ -264,7 +264,7 @@ private function writeStatementToFile(If_ $ifStatement): void
{
$content = $this->printer->prettyPrint([$ifStatement]);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/tx_scheduler_task.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, PHP_EOL . $content . PHP_EOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ public function refactor(Node $node): ?Node
// Reconstruct the original statement type (Return or Assignment)
if ($isReturn) {
$finalStmt = new Return_($replacementNode);
} elseif (! $assignNode instanceof Assign) {
return null;
} else {
// Re-use the original variable for assignment
/** @var Assign $assignNode */
$uriAssign = new Assign($assignNode->var, $replacementNode);
$finalStmt = new Expression($uriAssign);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private function shouldSkip(Expression $node): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}

private function createNewAssignmentTarget(Expr $classConstFetch): ArrayDimFetch
Expand All @@ -261,7 +261,7 @@ private function writeStatementToFile(If_ $ifStatement): void
{
$content = $this->printer->prettyPrint([$ifStatement]);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/tx_scheduler_task.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, PHP_EOL . $content . PHP_EOL);
Expand Down
4 changes: 2 additions & 2 deletions rules/TYPO314/v0/MoveSchedulerFrequencyOptionsToTCARector.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private function shouldSkip(Expression $node): bool
return true;
}

return ! $this->filesFinder->isExtLocalConf($this->file->getFilePath());
return ! $this->filesFinder->isExtLocalConf($this->getFile()->getFilePath());
}

private function createNewAssignmentTarget(): ArrayDimFetch
Expand All @@ -201,7 +201,7 @@ private function writeStatementToFile(Expression $expression): void
{
$content = $this->printer->prettyPrint([$expression]);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/tx_scheduler_task.php';
if ($this->filesystem->fileExists($newConfigurationFile)) {
$this->filesystem->appendToFile($newConfigurationFile, PHP_EOL . $content . PHP_EOL);
Expand Down
4 changes: 2 additions & 2 deletions rules/TYPO314/v0/RequireComposerJsonInClassicModeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function refactor(Node $node): ?Node
}

// Determine the extension root directory and key
$directory = dirname($this->file->getFilePath());
$directory = dirname($this->getFile()->getFilePath());
$composerJsonPath = $directory . '/composer.json';

if ($this->filesystem->fileExists($composerJsonPath)) {
Expand Down Expand Up @@ -278,7 +278,7 @@ public function refactor(Node $node): ?Node

private function shouldSkip(Assign $node): bool
{
if (! $this->filesFinder->isExtEmConf($this->file->getFilePath())) {
if (! $this->filesFinder->isExtEmConf($this->getFile()->getFilePath())) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function refactor(Node $node): ?int
$allowedRecordTypesString
);

$directoryName = dirname($this->file->getFilePath());
$directoryName = dirname($this->getFile()->getFilePath());
$newConfigurationFile = $directoryName . '/Configuration/TCA/Overrides/pages.php';

if ($this->filesystem->fileExists($newConfigurationFile)) {
Expand Down Expand Up @@ -170,6 +170,6 @@ private function shouldSkip(MethodCall $methodCall): bool
return true;
}

return ! $this->filesFinder->isExtTables($this->file->getFilePath());
return ! $this->filesFinder->isExtTables($this->getFile()->getFilePath());
}
}
4 changes: 2 additions & 2 deletions src/Helper/ExtensionKeyResolverTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private function resolvePotentialExtensionKeyByExtensionKeyParameter($contentArg
return null;
}

$resolvedExtensionKey = $this->composerExtensionKeyResolver->resolveExtensionKey($this->file);
$resolvedExtensionKey = $this->composerExtensionKeyResolver->resolveExtensionKey($this->getFile());
if ($resolvedExtensionKey === null) {
return null;
}
Expand Down Expand Up @@ -60,7 +60,7 @@ private function resolvePotentialExtensionKeyByConcatenation($contentArgumentVal
return;
}

$resolvedExtensionKey = $this->composerExtensionKeyResolver->resolveExtensionKey($this->file);
$resolvedExtensionKey = $this->composerExtensionKeyResolver->resolveExtensionKey($this->getFile());
if ($resolvedExtensionKey === null) {
return;
}
Expand Down