recursion is not needed, as Rector now works till there is something to change

This commit is contained in:
Tomas Votruba 2021-08-02 17:50:38 +02:00
parent 66e21558ba
commit 5145487e37
2 changed files with 1 additions and 284 deletions

View File

@ -1,4 +1,4 @@
# 490 Rules Overview
# 476 Rules Overview
<br>
@ -52,8 +52,6 @@
- [Order](#order) (1)
- [PHPOffice](#phpoffice) (14)
- [PSR4](#psr4) (2)
- [Php52](#php52) (2)
@ -6155,283 +6153,6 @@ Order private methods in order of their use
<br>
## PHPOffice
### AddRemovedDefaultValuesRector
Complete removed default values explicitly
- class: [`Rector\PHPOffice\Rector\StaticCall\AddRemovedDefaultValuesRector`](../rules/PHPOffice/Rector/StaticCall/AddRemovedDefaultValuesRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$logger = new \PHPExcel_CalcEngine_Logger;
- $logger->setWriteDebugLog();
+ $logger->setWriteDebugLog(false);
}
}
```
<br>
### CellStaticToCoordinateRector
Methods to manipulate coordinates that used to exists in PHPExcel_Cell to PhpOffice\PhpSpreadsheet\Cell\Coordinate
- class: [`Rector\PHPOffice\Rector\StaticCall\CellStaticToCoordinateRector`](../rules/PHPOffice/Rector/StaticCall/CellStaticToCoordinateRector.php)
```diff
class SomeClass
{
public function run()
{
- \PHPExcel_Cell::stringFromColumnIndex();
+ \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex();
}
}
```
<br>
### ChangeChartRendererRector
Change chart renderer
- class: [`Rector\PHPOffice\Rector\StaticCall\ChangeChartRendererRector`](../rules/PHPOffice/Rector/StaticCall/ChangeChartRendererRector.php)
```diff
final class SomeClass
{
public function run(): void
{
- \PHPExcel_Settings::setChartRenderer($rendererName, $rendererLibraryPath);
+ \PHPExcel_Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
}
}
```
<br>
### ChangeConditionalGetConditionRector
Change argument `PHPExcel_Style_Conditional->getCondition()` to `getConditions()`
- class: [`Rector\PHPOffice\Rector\MethodCall\ChangeConditionalGetConditionRector`](../rules/PHPOffice/Rector/MethodCall/ChangeConditionalGetConditionRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$conditional = new \PHPExcel_Style_Conditional;
- $someCondition = $conditional->getCondition();
+ $someCondition = $conditional->getConditions()[0] ?? '';
}
}
```
<br>
### ChangeConditionalReturnedCellRector
Change conditional call to `getCell()`
- class: [`Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector`](../rules/PHPOffice/Rector/MethodCall/ChangeConditionalReturnedCellRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$worksheet = new \PHPExcel_Worksheet();
- $cell = $worksheet->setCellValue('A1', 'value', true);
+ $cell = $worksheet->getCell('A1')->setValue('value');
}
}
```
<br>
### ChangeConditionalSetConditionRector
Change argument `PHPExcel_Style_Conditional->setCondition()` to `setConditions()`
- class: [`Rector\PHPOffice\Rector\MethodCall\ChangeConditionalSetConditionRector`](../rules/PHPOffice/Rector/MethodCall/ChangeConditionalSetConditionRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$conditional = new \PHPExcel_Style_Conditional;
- $someCondition = $conditional->setCondition(1);
+ $someCondition = $conditional->setConditions((array) 1);
}
}
```
<br>
### ChangeDataTypeForValueRector
Change argument `DataType::dataTypeForValue()` to DefaultValueBinder
- class: [`Rector\PHPOffice\Rector\StaticCall\ChangeDataTypeForValueRector`](../rules/PHPOffice/Rector/StaticCall/ChangeDataTypeForValueRector.php)
```diff
final class SomeClass
{
public function run(): void
{
- $type = \PHPExcel_Cell_DataType::dataTypeForValue('value');
+ $type = \PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::dataTypeForValue('value');
}
}
```
<br>
### ChangeDuplicateStyleArrayToApplyFromArrayRector
Change method call `duplicateStyleArray()` to `getStyle()` + `applyFromArray()`
- class: [`Rector\PHPOffice\Rector\MethodCall\ChangeDuplicateStyleArrayToApplyFromArrayRector`](../rules/PHPOffice/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$worksheet = new \PHPExcel_Worksheet();
- $worksheet->duplicateStyleArray($styles, $range, $advanced);
+ $worksheet->getStyle($range)->applyFromArray($styles, $advanced);
}
}
```
<br>
### ChangeIOFactoryArgumentRector
Change argument of `PHPExcel_IOFactory::createReader()`, `PHPExcel_IOFactory::createWriter()` and `PHPExcel_IOFactory::identify()`
- class: [`Rector\PHPOffice\Rector\StaticCall\ChangeIOFactoryArgumentRector`](../rules/PHPOffice/Rector/StaticCall/ChangeIOFactoryArgumentRector.php)
```diff
final class SomeClass
{
public function run(): void
{
- $writer = \PHPExcel_IOFactory::createWriter('CSV');
+ $writer = \PHPExcel_IOFactory::createWriter('Csv');
}
}
```
<br>
### ChangePdfWriterRector
Change init of PDF writer
- class: [`Rector\PHPOffice\Rector\StaticCall\ChangePdfWriterRector`](../rules/PHPOffice/Rector/StaticCall/ChangePdfWriterRector.php)
```diff
final class SomeClass
{
public function run(): void
{
- \PHPExcel_Settings::setPdfRendererName(PHPExcel_Settings::PDF_RENDERER_MPDF);
- \PHPExcel_Settings::setPdfRenderer($somePath);
- $writer = \PHPExcel_IOFactory::createWriter($spreadsheet, 'PDF');
+ $writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet);
}
}
```
<br>
### ChangeSearchLocationToRegisterReaderRector
Change argument `addSearchLocation()` to `registerReader()`
- class: [`Rector\PHPOffice\Rector\StaticCall\ChangeSearchLocationToRegisterReaderRector`](../rules/PHPOffice/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php)
```diff
final class SomeClass
{
public function run(): void
{
- \PHPExcel_IOFactory::addSearchLocation($type, $location, $classname);
+ \PhpOffice\PhpSpreadsheet\IOFactory::registerReader($type, $classname);
}
}
```
<br>
### GetDefaultStyleToGetParentRector
Methods to (new `Worksheet())->getDefaultStyle()` to `getParent()->getDefaultStyle()`
- class: [`Rector\PHPOffice\Rector\MethodCall\GetDefaultStyleToGetParentRector`](../rules/PHPOffice/Rector/MethodCall/GetDefaultStyleToGetParentRector.php)
```diff
class SomeClass
{
public function run()
{
$worksheet = new \PHPExcel_Worksheet();
- $worksheet->getDefaultStyle();
+ $worksheet->getParent()->getDefaultStyle();
}
}
```
<br>
### IncreaseColumnIndexRector
Column index changed from 0 to 1 - run only ONCE! changes current value without memory
- class: [`Rector\PHPOffice\Rector\MethodCall\IncreaseColumnIndexRector`](../rules/PHPOffice/Rector/MethodCall/IncreaseColumnIndexRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$worksheet = new \PHPExcel_Worksheet();
- $worksheet->setCellValueByColumnAndRow(0, 3, '1150');
+ $worksheet->setCellValueByColumnAndRow(1, 3, '1150');
}
}
```
<br>
### RemoveSetTempDirOnExcelWriterRector
Remove `setTempDir()` on PHPExcel_Writer_Excel5
- class: [`Rector\PHPOffice\Rector\MethodCall\RemoveSetTempDirOnExcelWriterRector`](../rules/PHPOffice/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php)
```diff
final class SomeClass
{
public function run(): void
{
$writer = new \PHPExcel_Writer_Excel5;
- $writer->setTempDir();
}
}
```
<br>
## PSR4
### MultipleClassFileToPsr4ClassesRector

View File

@ -98,10 +98,6 @@ CODE_SAMPLE
while ($changedNode !== null && ! $this->nodeComparator->areNodesEqual($previousNode, $changedNode)) {
$previousNode = $changedNode;
if ($changedNode instanceof BinaryOp || $changedNode instanceof AssignOp) {
$changedNode = $this->refactor($changedNode);
}
// nothing more to change, return last node
if (! $changedNode instanceof Node) {
return $previousNode;