mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 08:20:53 +00:00
Updated Rector to commit 00fb10f8a5
8c4c7d0ae7
recursion is not needed, as Rector now works till there is something to change00fb10f8a5
fix cs
This commit is contained in:
parent
4a5ca2c9e5
commit
fb7f804b70
|
@ -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
|
||||
|
|
|
@ -10,7 +10,6 @@ use PhpParser\Node\Expr\AssignOp\Div as AssignDiv;
|
|||
use PhpParser\Node\Expr\AssignOp\Minus as AssignMinus;
|
||||
use PhpParser\Node\Expr\AssignOp\Mul as AssignMul;
|
||||
use PhpParser\Node\Expr\AssignOp\Plus as AssignPlus;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Div;
|
||||
use PhpParser\Node\Expr\BinaryOp\Minus;
|
||||
use PhpParser\Node\Expr\BinaryOp\Mul;
|
||||
|
@ -62,27 +61,13 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$changedNode = null;
|
||||
$previousNode = $node;
|
||||
// $changedNode = null;
|
||||
// $previousNode = $node;
|
||||
if ($node instanceof \PhpParser\Node\Expr\AssignOp) {
|
||||
$changedNode = $this->processAssignOp($node);
|
||||
return $this->processAssignOp($node);
|
||||
}
|
||||
// -, +
|
||||
if ($node instanceof \PhpParser\Node\Expr\BinaryOp) {
|
||||
$changedNode = $this->processBinaryOp($node);
|
||||
}
|
||||
// recurse nested combinations
|
||||
while ($changedNode !== null && !$this->nodeComparator->areNodesEqual($previousNode, $changedNode)) {
|
||||
$previousNode = $changedNode;
|
||||
if ($changedNode instanceof \PhpParser\Node\Expr\BinaryOp || $changedNode instanceof \PhpParser\Node\Expr\AssignOp) {
|
||||
$changedNode = $this->refactor($changedNode);
|
||||
}
|
||||
// nothing more to change, return last node
|
||||
if (!$changedNode instanceof \PhpParser\Node) {
|
||||
return $previousNode;
|
||||
}
|
||||
}
|
||||
return $changedNode;
|
||||
return $this->processBinaryOp($node);
|
||||
}
|
||||
private function processAssignOp(\PhpParser\Node $node) : ?\PhpParser\Node\Expr
|
||||
{
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '66e21558ba914cba2549e1940ef1e0fd7b4e6521';
|
||||
public const PACKAGE_VERSION = '00fb10f8a50491ab39eabf924d3da805860fb1a2';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-08-02 17:47:23';
|
||||
public const RELEASE_DATE = '2021-08-02 17:52:34';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210802\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686::getLoader();
|
||||
return ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507::getLoader();
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686
|
||||
class ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit42b79f7d00222661bde0f680f91ca686::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit42b79f7d00222661bde0f680f91ca686::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire42b79f7d00222661bde0f680f91ca686($fileIdentifier, $file);
|
||||
composerRequire3ba205858d4eaa477d41c7d509ef8507($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire42b79f7d00222661bde0f680f91ca686($fileIdentifier, $file)
|
||||
function composerRequire3ba205858d4eaa477d41c7d509ef8507($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit42b79f7d00222661bde0f680f91ca686
|
||||
class ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3847,9 +3847,9 @@ class ComposerStaticInit42b79f7d00222661bde0f680f91ca686
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit42b79f7d00222661bde0f680f91ca686::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit42b79f7d00222661bde0f680f91ca686::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit42b79f7d00222661bde0f680f91ca686::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3ba205858d4eaa477d41c7d509ef8507::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20210802\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686', false) && !interface_exists('ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686', false) && !trait_exists('ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686', false)) {
|
||||
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInit42b79f7d00222661bde0f680f91ca686');
|
||||
if (!class_exists('ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507', false) && !interface_exists('ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507', false) && !trait_exists('ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507', false)) {
|
||||
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInit3ba205858d4eaa477d41c7d509ef8507');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210802\Doctrine\Inflector\Inflector');
|
||||
|
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210802\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire42b79f7d00222661bde0f680f91ca686')) {
|
||||
function composerRequire42b79f7d00222661bde0f680f91ca686() {
|
||||
return \RectorPrefix20210802\composerRequire42b79f7d00222661bde0f680f91ca686(...func_get_args());
|
||||
if (!function_exists('composerRequire3ba205858d4eaa477d41c7d509ef8507')) {
|
||||
function composerRequire3ba205858d4eaa477d41c7d509ef8507() {
|
||||
return \RectorPrefix20210802\composerRequire3ba205858d4eaa477d41c7d509ef8507(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user