mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit c12f90964a75280c3803eb1c147c51d570411985
c12f90964a
Make Rector PHPOffice optional package, as only migrates ~7 years old version (#3061)
This commit is contained in:
parent
46ee9a173a
commit
e6a22bed57
|
@ -23,7 +23,6 @@
|
|||
"rector/rector-phpunit": "*",
|
||||
"rector/rector-symfony": "*",
|
||||
"rector/rector-doctrine": "*",
|
||||
"rector/rector-phpoffice": "*",
|
||||
"rector/rector-php-parser": "*",
|
||||
"rector/rector-downgrade-php": "*"
|
||||
},
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '0.14.8';
|
||||
public const PACKAGE_VERSION = 'c12f90964a75280c3803eb1c147c51d570411985';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-11-13 15:53:04';
|
||||
public const RELEASE_DATE = '2022-11-14 15:03:12';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c::getLoader();
|
||||
return ComposerAutoloaderInite26fff598c3684250a355946b3fd7251::getLoader();
|
||||
|
|
|
@ -1933,23 +1933,6 @@ return array(
|
|||
'Rector\\NodeTypeResolver\\TypeComparator\\ScalarTypeComparator' => $baseDir . '/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php',
|
||||
'Rector\\NodeTypeResolver\\TypeComparator\\TypeComparator' => $baseDir . '/packages/NodeTypeResolver/TypeComparator/TypeComparator.php',
|
||||
'Rector\\NodeTypeResolver\\ValueObject\\OldToNewType' => $baseDir . '/packages/NodeTypeResolver/ValueObject/OldToNewType.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalGetConditionRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalReturnedCellRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalSetConditionRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeDuplicateStyleArrayToApplyFromArrayRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\GetDefaultStyleToGetParentRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\IncreaseColumnIndexRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\RemoveSetTempDirOnExcelWriterRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\AddRemovedDefaultValuesRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\CellStaticToCoordinateRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeChartRendererRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeDataTypeForValueRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeIOFactoryArgumentRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangePdfWriterRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeSearchLocationToRegisterReaderRector' => $vendorDir . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php',
|
||||
'Rector\\PHPOffice\\Set\\PHPOfficeSetList' => $vendorDir . '/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php',
|
||||
'Rector\\PHPOffice\\ValueObject\\ConditionalSetValue' => $vendorDir . '/rector/rector-phpoffice/src/ValueObject/ConditionalSetValue.php',
|
||||
'Rector\\PHPOffice\\ValueObject\\PHPExcelMethodDefaultValues' => $vendorDir . '/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Contract\\TypeMapperInterface' => $baseDir . '/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\DoctrineTypeAnalyzer' => $baseDir . '/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Enum\\TypeKind' => $baseDir . '/packages/PHPStanStaticTypeMapper/Enum/TypeKind.php',
|
||||
|
|
|
@ -14,7 +14,6 @@ return array(
|
|||
'Rector\\RectorInstaller\\' => array($vendorDir . '/rector/extension-installer/src'),
|
||||
'Rector\\PhpParser\\' => array($vendorDir . '/rector/rector-php-parser/src'),
|
||||
'Rector\\PHPUnit\\' => array($vendorDir . '/rector/rector-phpunit/src'),
|
||||
'Rector\\PHPOffice\\' => array($vendorDir . '/rector/rector-phpoffice/src'),
|
||||
'Rector\\Doctrine\\' => array($vendorDir . '/rector/rector-doctrine/src'),
|
||||
'Rector\\Core\\' => array($baseDir . '/src'),
|
||||
'Rector\\' => array($baseDir . '/packages', $baseDir . '/rules', $vendorDir . '/rector/rector-downgrade-php/src', $vendorDir . '/rector/rector-downgrade-php/rules'),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c
|
||||
class ComposerAutoloaderInite26fff598c3684250a355946b3fd7251
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInite26fff598c3684250a355946b3fd7251', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite26fff598c3684250a355946b3fd7251', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite26fff598c3684250a355946b3fd7251::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInite26fff598c3684250a355946b3fd7251::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire2b04441d1fb4ab60085e1ed0db63132c($fileIdentifier, $file);
|
||||
composerRequiree26fff598c3684250a355946b3fd7251($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire2b04441d1fb4ab60085e1ed0db63132c($fileIdentifier, $file)
|
||||
function composerRequiree26fff598c3684250a355946b3fd7251($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c
|
||||
class ComposerStaticInite26fff598c3684250a355946b3fd7251
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -31,7 +31,6 @@ class ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
'Rector\\RectorInstaller\\' => 23,
|
||||
'Rector\\PhpParser\\' => 17,
|
||||
'Rector\\PHPUnit\\' => 15,
|
||||
'Rector\\PHPOffice\\' => 17,
|
||||
'Rector\\Doctrine\\' => 16,
|
||||
'Rector\\Core\\' => 12,
|
||||
'Rector\\' => 7,
|
||||
|
@ -106,10 +105,6 @@ class ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
array (
|
||||
0 => __DIR__ . '/..' . '/rector/rector-phpunit/src',
|
||||
),
|
||||
'Rector\\PHPOffice\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/rector/rector-phpoffice/src',
|
||||
),
|
||||
'Rector\\Doctrine\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/rector/rector-doctrine/src',
|
||||
|
@ -2183,23 +2178,6 @@ class ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
'Rector\\NodeTypeResolver\\TypeComparator\\ScalarTypeComparator' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php',
|
||||
'Rector\\NodeTypeResolver\\TypeComparator\\TypeComparator' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/TypeComparator/TypeComparator.php',
|
||||
'Rector\\NodeTypeResolver\\ValueObject\\OldToNewType' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/ValueObject/OldToNewType.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalGetConditionRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalReturnedCellRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeConditionalSetConditionRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\ChangeDuplicateStyleArrayToApplyFromArrayRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\GetDefaultStyleToGetParentRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\IncreaseColumnIndexRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\MethodCall\\RemoveSetTempDirOnExcelWriterRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\AddRemovedDefaultValuesRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\CellStaticToCoordinateRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeChartRendererRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeDataTypeForValueRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeIOFactoryArgumentRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangePdfWriterRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php',
|
||||
'Rector\\PHPOffice\\Rector\\StaticCall\\ChangeSearchLocationToRegisterReaderRector' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php',
|
||||
'Rector\\PHPOffice\\Set\\PHPOfficeSetList' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php',
|
||||
'Rector\\PHPOffice\\ValueObject\\ConditionalSetValue' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/ValueObject/ConditionalSetValue.php',
|
||||
'Rector\\PHPOffice\\ValueObject\\PHPExcelMethodDefaultValues' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Contract\\TypeMapperInterface' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\DoctrineTypeAnalyzer' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Enum\\TypeKind' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Enum/TypeKind.php',
|
||||
|
@ -3054,9 +3032,9 @@ class ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2b04441d1fb4ab60085e1ed0db63132c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite26fff598c3684250a355946b3fd7251::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite26fff598c3684250a355946b3fd7251::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite26fff598c3684250a355946b3fd7251::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -1784,12 +1784,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "17bdb82a53af4f58dfb4c00634e8942e653bfaef"
|
||||
"reference": "bf394eec1e4612ceae5b6ee3c574e37f81f422b7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/17bdb82a53af4f58dfb4c00634e8942e653bfaef",
|
||||
"reference": "17bdb82a53af4f58dfb4c00634e8942e653bfaef",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/bf394eec1e4612ceae5b6ee3c574e37f81f422b7",
|
||||
"reference": "bf394eec1e4612ceae5b6ee3c574e37f81f422b7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1815,7 +1815,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-10-26T10:28:39+00:00",
|
||||
"time": "2022-11-14T14:41:41+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1924,12 +1924,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-php-parser.git",
|
||||
"reference": "9c21f5f57464fc5af8765a1007eced8f7f62677c"
|
||||
"reference": "9ea5f622c1ed47addb197ded25a6bac39c39c596"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-php-parser\/zipball\/9c21f5f57464fc5af8765a1007eced8f7f62677c",
|
||||
"reference": "9c21f5f57464fc5af8765a1007eced8f7f62677c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-php-parser\/zipball\/9ea5f622c1ed47addb197ded25a6bac39c39c596",
|
||||
"reference": "9ea5f622c1ed47addb197ded25a6bac39c39c596",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1954,7 +1954,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-09-26T00:05:09+00:00",
|
||||
"time": "2022-11-14T14:42:43+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1981,77 +1981,10 @@
|
|||
"description": "Rector upgrades rules for PHP-Parser",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector-php-parser\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-php-parser\/tree\/0.14.0"
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-php-parser\/tree\/main"
|
||||
},
|
||||
"install-path": "..\/rector\/rector-php-parser"
|
||||
},
|
||||
{
|
||||
"name": "rector\/rector-phpoffice",
|
||||
"version": "dev-main",
|
||||
"version_normalized": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpoffice.git",
|
||||
"reference": "294de0ce80a9eb2c1b2d0d8e2762032dba0044e0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpoffice\/zipball\/294de0ce80a9eb2c1b2d0d8e2762032dba0044e0",
|
||||
"reference": "294de0ce80a9eb2c1b2d0d8e2762032dba0044e0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"conflict": {
|
||||
"rector\/rector": "<0.12"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpstan\/phpstan": "^1.8.2",
|
||||
"phpstan\/phpstan-strict-rules": "^1.3",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"phpunit\/phpunit": "^9.5.21",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-coding-standard": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/phpstan-rules": "^11.1",
|
||||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-09-02T10:42:26+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
"enable-patching": true,
|
||||
"branch-alias": {
|
||||
"dev-main": "0.11-dev"
|
||||
},
|
||||
"rector": {
|
||||
"includes": [
|
||||
"config\/config.php"
|
||||
]
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\PHPOffice\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Rector upgrades rules for PHP Office",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector-phpoffice\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-phpoffice\/tree\/main"
|
||||
},
|
||||
"install-path": "..\/rector\/rector-phpoffice"
|
||||
},
|
||||
{
|
||||
"name": "rector\/rector-phpunit",
|
||||
"version": "dev-main",
|
||||
|
@ -2059,12 +1992,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "e572a473079d5ff39a7c6f5b11ef925896121017"
|
||||
"reference": "769064fc1622bb6e31da6d6802b1bcdaea08e007"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/e572a473079d5ff39a7c6f5b11ef925896121017",
|
||||
"reference": "e572a473079d5ff39a7c6f5b11ef925896121017",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/769064fc1622bb6e31da6d6802b1bcdaea08e007",
|
||||
"reference": "769064fc1622bb6e31da6d6802b1bcdaea08e007",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2090,7 +2023,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-11-14T13:59:10+00:00",
|
||||
"time": "2022-11-14T14:37:39+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2128,12 +2061,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "8b6330201a4254dbc222075637d145b2475a1079"
|
||||
"reference": "695c960e7713438ef1077bebcbc6d298a95020d1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/8b6330201a4254dbc222075637d145b2475a1079",
|
||||
"reference": "8b6330201a4254dbc222075637d145b2475a1079",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/695c960e7713438ef1077bebcbc6d298a95020d1",
|
||||
"reference": "695c960e7713438ef1077bebcbc6d298a95020d1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2164,7 +2097,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-11-12T17:52:04+00:00",
|
||||
"time": "2022-11-14T14:41:53+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 17bdb82'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main da1013f'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9c21f5f'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e572a47'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8b63302'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main bf394ee'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main da1013f'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 769064f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 695c960'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
The MIT License
|
||||
---------------
|
||||
|
||||
Copyright (c) 2017-present Tomáš Votruba (https://tomasvotruba.cz)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,39 +0,0 @@
|
|||
# Rector Rules for PHP Office
|
||||
|
||||
See available [PHP Office rules](/docs/rector_rules_overview.md)
|
||||
|
||||
## Install
|
||||
|
||||
This package is already part of [rector/rector](http://github.com/rectorphp/rector) package, so it works out of the box.
|
||||
|
||||
All you need to do is install the main package, and you're good to go:
|
||||
|
||||
```bash
|
||||
composer require rector/rector --dev
|
||||
```
|
||||
|
||||
## Use Sets
|
||||
|
||||
To add a set to your config, use `Rector\PHPOffice\Set\PHPOfficeSetList` class and pick one of constants:
|
||||
|
||||
```php
|
||||
use Rector\PHPOffice\Set\PHPOfficeSetList;
|
||||
use Rector\Config\RectorConfig;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->sets([
|
||||
PHPOfficeSetList::PHPEXCEL_TO_PHPSPREADSHEET
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Learn Rector Faster
|
||||
|
||||
Rector is a tool that [we develop](https://getrector.org/) and share for free, so anyone can save hundreds of hours on refactoring. But not everyone has time to understand Rector and AST complexity. You have 2 ways to speed this process up:
|
||||
|
||||
* read a book - <a href="https://leanpub.com/rector-the-power-of-automated-refactoring">The Power of Automated Refactoring</a>
|
||||
* hire our experienced team to <a href="https://getrector.org/contact">improve your code base</a>
|
||||
|
||||
Both ways support us to and improve Rector in sustainable way by learning from practical projects.
|
|
@ -1,66 +0,0 @@
|
|||
{
|
||||
"name": "rector\/rector-phpoffice",
|
||||
"type": "rector-extension",
|
||||
"license": "MIT",
|
||||
"description": "Rector upgrades rules for PHP Office",
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpunit\/phpunit": "^9.5.21",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"phpstan\/phpstan": "^1.8.2",
|
||||
"symplify\/phpstan-rules": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/easy-coding-standard": "^11.1",
|
||||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"phpstan\/phpstan-strict-rules": "^1.3",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"symplify\/vendor-patches": "^11.1",
|
||||
"rector\/rector-debugging": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\PHPOffice\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Rector\\PHPOffice\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"phpstan": "vendor\/bin\/phpstan analyse --ansi --error-format symplify",
|
||||
"check-cs": "vendor\/bin\/ecs check --ansi",
|
||||
"fix-cs": "vendor\/bin\/ecs check --fix --ansi",
|
||||
"docs": [
|
||||
"vendor\/bin\/rule-doc-generator generate src --output-file docs\/rector_rules_overview.md --ansi",
|
||||
"vendor\/bin\/ecs check-markdown docs\/rector_rules_overview.md --ansi --fix"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"enable-patching": true,
|
||||
"branch-alias": {
|
||||
"dev-main": "0.11-dev"
|
||||
},
|
||||
"rector": {
|
||||
"includes": [
|
||||
"config\/config.php"
|
||||
]
|
||||
}
|
||||
},
|
||||
"conflict": {
|
||||
"rector\/rector": "<0.12"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"cweagans\/composer-patches": true,
|
||||
"rector\/extension-installer": true,
|
||||
"phpstan\/extension-installer": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202211;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$services = $rectorConfig->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\PHPOffice\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Set', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']);
|
||||
};
|
File diff suppressed because one or more lines are too long
|
@ -1,276 +0,0 @@
|
|||
# 14 Rules Overview
|
||||
|
||||
## AddRemovedDefaultValuesRector
|
||||
|
||||
Complete removed default values explicitly
|
||||
|
||||
- class: [`Rector\PHPOffice\Rector\StaticCall\AddRemovedDefaultValuesRector`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/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`](../src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php)
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = new \PHPExcel_Writer_Excel5;
|
||||
- $writer->setTempDir();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202211;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Rector\Set\ValueObject\LevelSetList;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::CODE_QUALITY, SetList::DEAD_CODE, SetList::NAMING]);
|
||||
$rectorConfig->importNames();
|
||||
$rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
$rectorConfig->skip([StringClassNameToClassConstantRector::class => [__DIR__ . '/config']]);
|
||||
$rectorConfig->parallel();
|
||||
};
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\BinaryOp\Coalesce;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#conditionalgetcondition
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalGetConditionRector\ChangeConditionalGetConditionRectorTest
|
||||
*/
|
||||
final class ChangeConditionalGetConditionRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change argument PHPExcel_Style_Conditional->getCondition() to getConditions()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$conditional = new \PHPExcel_Style_Conditional;
|
||||
$someCondition = $conditional->getCondition();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$conditional = new \PHPExcel_Style_Conditional;
|
||||
$someCondition = $conditional->getConditions()[0] ?? '';
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Style_Conditional'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'getCondition')) {
|
||||
return null;
|
||||
}
|
||||
$node->name = new Identifier('getConditions');
|
||||
$arrayDimFetch = new ArrayDimFetch($node, new LNumber(0));
|
||||
return new Coalesce($arrayDimFetch, new String_(''));
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPOffice\ValueObject\ConditionalSetValue;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dropped-conditionally-returned-cell
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalReturnedCellRector\ChangeConditionalReturnedCellRectorTest
|
||||
*/
|
||||
final class ChangeConditionalReturnedCellRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var ConditionalSetValue[]
|
||||
*/
|
||||
private $conditionalSetValues = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->conditionalSetValues[] = new ConditionalSetValue('setCellValue', 'getCell', 'setValue', 2, \false);
|
||||
$this->conditionalSetValues[] = new ConditionalSetValue('setCellValueByColumnAndRow', 'getCellByColumnAndRow', 'setValue', 3, \true);
|
||||
$this->conditionalSetValues[] = new ConditionalSetValue('setCellValueExplicit', 'getCell', 'setValueExplicit', 3, \false);
|
||||
$this->conditionalSetValues[] = new ConditionalSetValue('setCellValueExplicitByColumnAndRow', 'getCellByColumnAndRow', 'setValueExplicit', 4, \true);
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change conditional call to getCell()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$cell = $worksheet->setCellValue('A1', 'value', true);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$cell = $worksheet->getCell('A1')->setValue('value');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->conditionalSetValues as $conditionalSetValue) {
|
||||
if (!$this->isName($node->name, $conditionalSetValue->getOldMethod())) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($node->args[$conditionalSetValue->getArgPosition()])) {
|
||||
continue;
|
||||
}
|
||||
$args = $node->args;
|
||||
unset($args[$conditionalSetValue->getArgPosition()]);
|
||||
$locationArgs = [];
|
||||
$locationArgs[] = $args[0];
|
||||
unset($args[0]);
|
||||
if ($conditionalSetValue->hasRow()) {
|
||||
$locationArgs[] = $args[1];
|
||||
unset($args[1]);
|
||||
}
|
||||
$variable = clone $node->var;
|
||||
$getCellMethodCall = new MethodCall($variable, $conditionalSetValue->getNewGetMethod(), $locationArgs);
|
||||
$node->var = $getCellMethodCall;
|
||||
$node->args = \array_values($args);
|
||||
$node->name = new Identifier($conditionalSetValue->getNewSetMethod());
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Cast\Array_;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#conditionalsetcondition
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalSetConditionRector\ChangeConditionalSetConditionRectorTest
|
||||
*/
|
||||
final class ChangeConditionalSetConditionRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change argument PHPExcel_Style_Conditional->setCondition() to setConditions()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$conditional = new \PHPExcel_Style_Conditional;
|
||||
$someCondition = $conditional->setCondition(1);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$conditional = new \PHPExcel_Style_Conditional;
|
||||
$someCondition = $conditional->setConditions((array) 1);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Style_Conditional'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'setCondition')) {
|
||||
return null;
|
||||
}
|
||||
$node->name = new Identifier('setConditions');
|
||||
$this->castArgumentToArrayIfNotArrayType($node);
|
||||
return $node;
|
||||
}
|
||||
private function castArgumentToArrayIfNotArrayType(MethodCall $methodCall) : void
|
||||
{
|
||||
$firstArgumentValue = $methodCall->args[0]->value;
|
||||
$firstArgumentStaticType = $this->getType($firstArgumentValue);
|
||||
if ($firstArgumentStaticType instanceof ArrayType) {
|
||||
return;
|
||||
}
|
||||
// cast to array if not an array
|
||||
$methodCall->args[0]->value = new Array_($firstArgumentValue);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#removed-deprecated-things
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeDuplicateStyleArrayToApplyFromArrayRector\ChangeDuplicateStyleArrayToApplyFromArrayRectorTest
|
||||
*/
|
||||
final class ChangeDuplicateStyleArrayToApplyFromArrayRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change method call duplicateStyleArray() to getStyle() + applyFromArray()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->duplicateStyleArray($styles, $range, $advanced);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->getStyle($range)->applyFromArray($styles, $advanced);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($node->name, 'duplicateStyleArray')) {
|
||||
return null;
|
||||
}
|
||||
$variable = clone $node->var;
|
||||
// pop out 2nd argument
|
||||
$secondArgument = $node->args[1];
|
||||
unset($node->args[1]);
|
||||
$getStyleMethodCall = new MethodCall($variable, 'getStyle', [$secondArgument]);
|
||||
$node->var = $getStyleMethodCall;
|
||||
$node->name = new Identifier('applyFromArray');
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dedicated-class-to-manipulate-coordinates
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\GetDefaultStyleToGetParentRector\GetDefaultStyleToGetParentRectorTest
|
||||
*/
|
||||
final class GetDefaultStyleToGetParentRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Methods to (new Worksheet())->getDefaultStyle() to getParent()->getDefaultStyle()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->getDefaultStyle();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->getParent()->getDefaultStyle();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'getDefaultStyle')) {
|
||||
return null;
|
||||
}
|
||||
$variable = clone $node->var;
|
||||
$getParentMethodCall = new MethodCall($variable, 'getParent');
|
||||
$node->var = $getParentMethodCall;
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Plus;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#column-index-based-on-1
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\IncreaseColumnIndexRector\IncreaseColumnIndexRectorTest
|
||||
*/
|
||||
final class IncreaseColumnIndexRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const ALREADY_CHANGED = 'already_changed';
|
||||
/**
|
||||
* @var ObjectType[]
|
||||
*/
|
||||
private $worksheetObjectTypes = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->worksheetObjectTypes = [new ObjectType('PHPExcel_Worksheet'), new ObjectType('PHPExcel_Worksheet_PageSetup')];
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Column index changed from 0 to 1 - run only ONCE! changes current value without memory', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->setCellValueByColumnAndRow(0, 3, '1150');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$worksheet = new \PHPExcel_Worksheet();
|
||||
$worksheet->setCellValueByColumnAndRow(1, 3, '1150');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->nodeTypeResolver->isObjectTypes($node->var, $this->worksheetObjectTypes)) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, '*ByColumnAndRow')) {
|
||||
return null;
|
||||
}
|
||||
$hasAlreadyChanged = (bool) $node->getAttribute(self::ALREADY_CHANGED, \false);
|
||||
if ($hasAlreadyChanged) {
|
||||
return null;
|
||||
}
|
||||
$node->setAttribute(self::ALREADY_CHANGED, \true);
|
||||
// increase column value
|
||||
$firstArg = $node->getArgs()[0];
|
||||
$firstArgumentValue = $firstArg->value;
|
||||
if ($firstArgumentValue instanceof LNumber) {
|
||||
++$firstArgumentValue->value;
|
||||
}
|
||||
if ($firstArgumentValue instanceof BinaryOp) {
|
||||
$this->refactorBinaryOp($firstArgumentValue);
|
||||
}
|
||||
if ($firstArgumentValue instanceof Variable) {
|
||||
$firstArg->value = new Plus($firstArgumentValue, new LNumber(1));
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
private function refactorBinaryOp(BinaryOp $binaryOp) : void
|
||||
{
|
||||
if ($binaryOp->left instanceof LNumber) {
|
||||
++$binaryOp->left->value;
|
||||
return;
|
||||
}
|
||||
if ($binaryOp->right instanceof LNumber) {
|
||||
++$binaryOp->right->value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#writerxlssettempdir
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\MethodCall\RemoveSetTempDirOnExcelWriterRector\RemoveSetTempDirOnExcelWriterRectorTest
|
||||
*/
|
||||
final class RemoveSetTempDirOnExcelWriterRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Remove setTempDir() on PHPExcel_Writer_Excel5', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = new \PHPExcel_Writer_Excel5;
|
||||
$writer->setTempDir();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = new \PHPExcel_Writer_Excel5;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Writer_Excel5'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'setTempDir')) {
|
||||
return null;
|
||||
}
|
||||
$this->removeNode($node);
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPOffice\ValueObject\PHPExcelMethodDefaultValues;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/commit/033a4bdad56340795a5bf7ec3c8a2fde005cda24 https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#removed-default-values
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\AddRemovedDefaultValuesRector\AddRemovedDefaultValuesRectorTest
|
||||
*/
|
||||
final class AddRemovedDefaultValuesRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hasChanged = \false;
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Complete removed default values explicitly', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$logger = new \PHPExcel_CalcEngine_Logger;
|
||||
$logger->setWriteDebugLog();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$logger = new \PHPExcel_CalcEngine_Logger;
|
||||
$logger->setWriteDebugLog(false);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class, MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall|MethodCall $node
|
||||
* @return null|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
foreach (PHPExcelMethodDefaultValues::METHOD_NAMES_BY_TYPE_WITH_VALUE as $type => $defaultValuesByMethodName) {
|
||||
if (!$this->isCallerObjectType($node, new ObjectType($type))) {
|
||||
continue;
|
||||
}
|
||||
foreach ($defaultValuesByMethodName as $methodName => $defaultValuesByPosition) {
|
||||
if (!$this->isName($node->name, $methodName)) {
|
||||
continue;
|
||||
}
|
||||
$this->refactorArgs($node, $defaultValuesByPosition);
|
||||
}
|
||||
}
|
||||
if (!$this->hasChanged) {
|
||||
return null;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<int, mixed> $defaultValuesByPosition
|
||||
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node
|
||||
*/
|
||||
private function refactorArgs($node, array $defaultValuesByPosition) : void
|
||||
{
|
||||
foreach ($defaultValuesByPosition as $position => $defaultValue) {
|
||||
// value is already set
|
||||
if (isset($node->args[$position])) {
|
||||
continue;
|
||||
}
|
||||
if (\is_string($defaultValue) && \strpos($defaultValue, '::') !== \false) {
|
||||
[$className, $constant] = \explode('::', $defaultValue);
|
||||
$classConstant = $this->nodeFactory->createClassConstFetch($className, $constant);
|
||||
$arg = new Arg($classConstant);
|
||||
} else {
|
||||
$arg = $this->nodeFactory->createArg($defaultValue);
|
||||
}
|
||||
$node->args[$position] = $arg;
|
||||
$this->hasChanged = \true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node
|
||||
*/
|
||||
private function isCallerObjectType($node, ObjectType $objectType) : bool
|
||||
{
|
||||
$caller = $node instanceof MethodCall ? $node->var : $node->class;
|
||||
return $this->isObjectType($caller, $objectType);
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dedicated-class-to-manipulate-coordinates
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\CellStaticToCoordinateRector\CellStaticToCoordinateRectorTest
|
||||
*/
|
||||
final class CellStaticToCoordinateRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const DECOUPLED_METHODS = ['absoluteCoordinate', 'absoluteReference', 'buildRange', 'columnIndexFromString', 'coordinateFromString', 'extractAllCellReferencesInRange', 'getRangeBoundaries', 'mergeRangesInCollection', 'rangeBoundaries', 'rangeDimension', 'splitRange', 'stringFromColumnIndex'];
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Methods to manipulate coordinates that used to exists in PHPExcel_Cell to PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
\PHPExcel_Cell::stringFromColumnIndex();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
\PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->class, new ObjectType('PHPExcel_Cell'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isNames($node->name, self::DECOUPLED_METHODS)) {
|
||||
return null;
|
||||
}
|
||||
$node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate');
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#rendering-charts
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeChartRendererRector\ChangeChartRendererRectorTest
|
||||
*/
|
||||
final class ChangeChartRendererRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change chart renderer', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
\PHPExcel_Settings::setChartRenderer($rendererName, $rendererLibraryPath);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
\PHPExcel_Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$callerType = $this->nodeTypeResolver->getType($node->class);
|
||||
if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Settings'))->yes()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($node->name, 'setChartRenderer')) {
|
||||
return null;
|
||||
}
|
||||
if (\count($node->args) === 1) {
|
||||
return null;
|
||||
}
|
||||
$arg = new Arg($this->nodeFactory->createClassConstReference('PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph'));
|
||||
$node->args = [$arg];
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#datatypedatatypeforvalue
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeDataTypeForValueRector\ChangeDataTypeForValueRectorTest
|
||||
*/
|
||||
final class ChangeDataTypeForValueRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change argument DataType::dataTypeForValue() to DefaultValueBinder', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$type = \PHPExcel_Cell_DataType::dataTypeForValue('value');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$type = \PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::dataTypeForValue('value');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$callerType = $this->nodeTypeResolver->getType($node->class);
|
||||
if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Cell_DataType'))->yes()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($node->name, 'dataTypeForValue')) {
|
||||
return null;
|
||||
}
|
||||
$node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder');
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#renamed-readers-and-writers
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeIOFactoryArgumentRector\ChangeIOFactoryArgumentRectorTest
|
||||
*/
|
||||
final class ChangeIOFactoryArgumentRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private const OLD_TO_NEW_TYPE = ['CSV' => 'Csv', 'Excel2003XML' => 'Xml', 'Excel2007' => 'Xlsx', 'Excel5' => 'Xls', 'Gnumeric' => 'Gnumeric', 'HTML' => 'Html', 'OOCalc' => 'Ods', 'OpenDocument' => 'Ods', 'PDF' => 'Pdf', 'SYLK' => 'Slk'];
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change argument of PHPExcel_IOFactory::createReader(), PHPExcel_IOFactory::createWriter() and PHPExcel_IOFactory::identify()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = \PHPExcel_IOFactory::createWriter('CSV');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = \PHPExcel_IOFactory::createWriter('Csv');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->class, new ObjectType('PHPExcel_IOFactory'))) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isNames($node->name, ['createReader', 'createWriter', 'identify'])) {
|
||||
return null;
|
||||
}
|
||||
$firstArgumentValue = $this->valueResolver->getValue($node->args[0]->value);
|
||||
$newValue = self::OLD_TO_NEW_TYPE[$firstArgumentValue] ?? null;
|
||||
if ($newValue === null) {
|
||||
return null;
|
||||
}
|
||||
$node->args[0]->value = new String_($newValue);
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#writing-pdf
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangePdfWriterRector\ChangePdfWriterRectorTest
|
||||
*/
|
||||
final class ChangePdfWriterRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change init of PDF writer', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
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');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$callerType = $this->nodeTypeResolver->getType($node->class);
|
||||
if ($this->isSettingsPdfRendererStaticCall($callerType, $node)) {
|
||||
$this->removeNode($node);
|
||||
return null;
|
||||
}
|
||||
if ($callerType->isSuperTypeOf(new ObjectType('PHPExcel_IOFactory'))->yes() && $this->nodeNameResolver->isName($node->name, 'createWriter')) {
|
||||
if (!isset($node->args[1])) {
|
||||
return null;
|
||||
}
|
||||
$secondArgValue = $this->valueResolver->getValue($node->args[1]->value);
|
||||
if (!\is_string($secondArgValue)) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils::isMatch($secondArgValue, '#pdf#i')) {
|
||||
return new New_(new FullyQualified('PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Mpdf'), [$node->args[0]]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function isSettingsPdfRendererStaticCall(Type $callerType, StaticCall $staticCall) : bool
|
||||
{
|
||||
if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Settings'))->yes()) {
|
||||
return \false;
|
||||
}
|
||||
return $this->nodeNameResolver->isNames($staticCall->name, ['setPdfRendererName', 'setPdfRenderer']);
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Rector\StaticCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#simplified-iofactory
|
||||
*
|
||||
* @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeSearchLocationToRegisterReaderRector\ChangeSearchLocationToRegisterReaderRectorTest
|
||||
*/
|
||||
final class ChangeSearchLocationToRegisterReaderRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change argument addSearchLocation() to registerReader()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
\PHPExcel_IOFactory::addSearchLocation($type, $location, $classname);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
\PhpOffice\PhpSpreadsheet\IOFactory::registerReader($type, $classname);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StaticCall::class];
|
||||
}
|
||||
/**
|
||||
* @param StaticCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$callerType = $this->nodeTypeResolver->getType($node->class);
|
||||
if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_IOFactory'))->yes()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'addSearchLocation')) {
|
||||
return null;
|
||||
}
|
||||
$node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\IOFactory');
|
||||
$node->name = new Identifier('registerReader');
|
||||
// remove middle argument
|
||||
$args = $node->args;
|
||||
unset($args[1]);
|
||||
$node->args = \array_values($args);
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\Set;
|
||||
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class PHPOfficeSetList implements SetListInterface
|
||||
{
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PHPEXCEL_TO_PHPSPREADSHEET = __DIR__ . '/../../config/sets/phpexcel-to-phpspreadsheet.php';
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPOffice\ValueObject;
|
||||
|
||||
final class ConditionalSetValue
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $oldMethod;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $newGetMethod;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $newSetMethod;
|
||||
/**
|
||||
* @readonly
|
||||
* @var int
|
||||
*/
|
||||
private $argPosition;
|
||||
/**
|
||||
* @readonly
|
||||
* @var bool
|
||||
*/
|
||||
private $hasRow;
|
||||
public function __construct(string $oldMethod, string $newGetMethod, string $newSetMethod, int $argPosition, bool $hasRow)
|
||||
{
|
||||
$this->oldMethod = $oldMethod;
|
||||
$this->newGetMethod = $newGetMethod;
|
||||
$this->newSetMethod = $newSetMethod;
|
||||
$this->argPosition = $argPosition;
|
||||
$this->hasRow = $hasRow;
|
||||
}
|
||||
public function getOldMethod() : string
|
||||
{
|
||||
return $this->oldMethod;
|
||||
}
|
||||
public function getArgPosition() : int
|
||||
{
|
||||
return $this->argPosition;
|
||||
}
|
||||
public function getNewGetMethod() : string
|
||||
{
|
||||
return $this->newGetMethod;
|
||||
}
|
||||
public function getNewSetMethod() : string
|
||||
{
|
||||
return $this->newSetMethod;
|
||||
}
|
||||
public function hasRow() : bool
|
||||
{
|
||||
return $this->hasRow;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -27,6 +27,8 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
SetList::CODING_STYLE,
|
||||
SetList::EARLY_RETURN,
|
||||
SetList::NAMING,
|
||||
SetList::TYPE_DECLARATION,
|
||||
SetList::PRIVATIZATION,
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
|
||||
// keep unprefixed to protected from downgrade
|
||||
|
|
|
@ -21,7 +21,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\ProphecyPHPDocRector\ProphecyPHPDocRectorTest
|
||||
*/
|
||||
class ProphecyPHPDocRector extends AbstractRector
|
||||
final class ProphecyPHPDocRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
|
|
Loading…
Reference in New Issue