Updated Rector to commit 5cd60b2607153f45ea7f113768593f9a364a1291

5cd60b2607 Add rector/rector-php-parser to require in composer.json (#2932)
This commit is contained in:
Tomas Votruba 2022-09-17 09:09:04 +00:00
parent 079d3637b2
commit c4794ecd48
18 changed files with 278 additions and 17 deletions

View File

@ -25,7 +25,8 @@
"rector/rector-doctrine": "*",
"rector/rector-cakephp": "*",
"rector/rector-laravel": "*",
"rector/rector-phpoffice": "*"
"rector/rector-phpoffice": "*",
"rector/rector-php-parser": "*"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '85a01836afa3c4a1617e91dfb1d7f365adfb77f1';
public const PACKAGE_VERSION = '5cd60b2607153f45ea7f113768593f9a364a1291';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-17 09:15:34';
public const RELEASE_DATE = '2022-09-17 09:03:31';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb::getLoader();
return ComposerAutoloaderInit4667e521b323ffc723efdb7aeff638a2::getLoader();

View File

@ -2333,6 +2333,7 @@ return array(
'Rector\\PhpDocParser\\PhpParser\\SmartPhpParserFactory' => $baseDir . '/packages/PhpDocParser/PhpParser/SmartPhpParserFactory.php',
'Rector\\PhpDocParser\\TypeAnalyzer\\ClassMethodReturnTypeResolver' => $baseDir . '/packages/PhpDocParser/TypeAnalyzer/ClassMethodReturnTypeResolver.php',
'Rector\\PhpDocParser\\ValueObject\\AttributeKey' => $baseDir . '/packages/PhpDocParser/ValueObject/AttributeKey.php',
'Rector\\PhpParser\\Set\\PhpParserSetList' => $vendorDir . '/rector/rector-php-parser/src/Set/PhpParserSetList.php',
'Rector\\PostRector\\Application\\PostFileProcessor' => $baseDir . '/packages/PostRector/Application/PostFileProcessor.php',
'Rector\\PostRector\\Collector\\NodesToAddCollector' => $baseDir . '/packages/PostRector/Collector/NodesToAddCollector.php',
'Rector\\PostRector\\Collector\\NodesToRemoveCollector' => $baseDir . '/packages/PostRector/Collector/NodesToRemoveCollector.php',

View File

@ -12,6 +12,7 @@ return array(
'Rector\\Utils\\' => array($baseDir . '/utils'),
'Rector\\Symfony\\' => array($vendorDir . '/rector/rector-symfony/src'),
'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\\Laravel\\' => array($vendorDir . '/rector/rector-laravel/src'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb
class ComposerAutoloaderInit4667e521b323ffc723efdb7aeff638a2
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit4667e521b323ffc723efdb7aeff638a2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit4667e521b323ffc723efdb7aeff638a2', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit8a91979a260e943f6ee7492dd636daeb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit4667e521b323ffc723efdb7aeff638a2::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit8a91979a260e943f6ee7492dd636daeb::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit4667e521b323ffc723efdb7aeff638a2::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire8a91979a260e943f6ee7492dd636daeb($fileIdentifier, $file);
composerRequire4667e521b323ffc723efdb7aeff638a2($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit8a91979a260e943f6ee7492dd636daeb
* @param string $file
* @return void
*/
function composerRequire8a91979a260e943f6ee7492dd636daeb($fileIdentifier, $file)
function composerRequire4667e521b323ffc723efdb7aeff638a2($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit8a91979a260e943f6ee7492dd636daeb
class ComposerStaticInit4667e521b323ffc723efdb7aeff638a2
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -29,6 +29,7 @@ class ComposerStaticInit8a91979a260e943f6ee7492dd636daeb
'Rector\\Utils\\' => 13,
'Rector\\Symfony\\' => 15,
'Rector\\RectorInstaller\\' => 23,
'Rector\\PhpParser\\' => 17,
'Rector\\PHPUnit\\' => 15,
'Rector\\PHPOffice\\' => 17,
'Rector\\Laravel\\' => 15,
@ -99,6 +100,10 @@ class ComposerStaticInit8a91979a260e943f6ee7492dd636daeb
array (
0 => __DIR__ . '/..' . '/rector/extension-installer/src',
),
'Rector\\PhpParser\\' =>
array (
0 => __DIR__ . '/..' . '/rector/rector-php-parser/src',
),
'Rector\\PHPUnit\\' =>
array (
0 => __DIR__ . '/..' . '/rector/rector-phpunit/src',
@ -2588,6 +2593,7 @@ class ComposerStaticInit8a91979a260e943f6ee7492dd636daeb
'Rector\\PhpDocParser\\PhpParser\\SmartPhpParserFactory' => __DIR__ . '/../..' . '/packages/PhpDocParser/PhpParser/SmartPhpParserFactory.php',
'Rector\\PhpDocParser\\TypeAnalyzer\\ClassMethodReturnTypeResolver' => __DIR__ . '/../..' . '/packages/PhpDocParser/TypeAnalyzer/ClassMethodReturnTypeResolver.php',
'Rector\\PhpDocParser\\ValueObject\\AttributeKey' => __DIR__ . '/../..' . '/packages/PhpDocParser/ValueObject/AttributeKey.php',
'Rector\\PhpParser\\Set\\PhpParserSetList' => __DIR__ . '/..' . '/rector/rector-php-parser/src/Set/PhpParserSetList.php',
'Rector\\PostRector\\Application\\PostFileProcessor' => __DIR__ . '/../..' . '/packages/PostRector/Application/PostFileProcessor.php',
'Rector\\PostRector\\Collector\\NodesToAddCollector' => __DIR__ . '/../..' . '/packages/PostRector/Collector/NodesToAddCollector.php',
'Rector\\PostRector\\Collector\\NodesToRemoveCollector' => __DIR__ . '/../..' . '/packages/PostRector/Collector/NodesToRemoveCollector.php',
@ -3094,9 +3100,9 @@ class ComposerStaticInit8a91979a260e943f6ee7492dd636daeb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit8a91979a260e943f6ee7492dd636daeb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8a91979a260e943f6ee7492dd636daeb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8a91979a260e943f6ee7492dd636daeb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit4667e521b323ffc723efdb7aeff638a2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4667e521b323ffc723efdb7aeff638a2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4667e521b323ffc723efdb7aeff638a2::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2054,6 +2054,73 @@
},
"install-path": "..\/rector\/rector-laravel"
},
{
"name": "rector\/rector-php-parser",
"version": "dev-main",
"version_normalized": "dev-main",
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-php-parser.git",
"reference": "8d6cbe9cb66130011f41050d65e7cf53cae6cc05"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-php-parser\/zipball\/8d6cbe9cb66130011f41050d65e7cf53cae6cc05",
"reference": "8d6cbe9cb66130011f41050d65e7cf53cae6cc05",
"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-17T07:18:28+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\\PhpParser\\": "src"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"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\/main"
},
"install-path": "..\/rector\/rector-php-parser"
},
{
"name": "rector\/rector-phpoffice",
"version": "dev-main",

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), '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 c56069f'), '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 d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), '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 cf30315'), '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 137e52b'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), '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 c56069f'), '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 d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), '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 8d6cbe9'), '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 cf30315'), '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 137e52b'));
private function __construct()
{
}

25
vendor/rector/rector-php-parser/LICENSE vendored Normal file
View File

@ -0,0 +1,25 @@
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.

View File

@ -0,0 +1,39 @@
# Rector Rules for PHPParser
See available [PHPParser 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\PhpParser\Set\PhpParserSetList` class and pick one of constants:
```php
use Rector\PhpParser\Set\PhpParserSetList;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
PhpParserSetList::PHP_PARSER_50
]);
};
```
<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.

View File

@ -0,0 +1,66 @@
{
"name": "rector\/rector-php-parser",
"type": "rector-extension",
"license": "MIT",
"description": "Rector upgrades rules for PHP-Parser",
"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\\PhpParser\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Rector\\PhpParser\\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
}
}
}

View File

@ -0,0 +1,11 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202209;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('Rector\\PhpParser\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Set', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']);
};

View File

@ -0,0 +1,10 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202209;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['PhpParser\\Node\\Expr\\ArrayItem' => 'PhpParser\\Node\\ArrayItem', 'PhpParser\\Node\\Expr\\ClosureUse' => 'PhpParser\\Node\\ClosureUse', 'PhpParser\\Node\\Scalar\\EncapsedStringPart' => 'PhpParser\\Node\\InterpolatedStringPart', 'PhpParser\\Node\\Scalar\\LNumber' => 'PhpParser\\Node\\Scalar\\Int_', 'PhpParser\\Node\\Stmt\\DeclareDeclare' => 'PhpParser\\Node\\DeclareItem', 'PhpParser\\Node\\Stmt\\PropertyProperty' => 'PhpParser\\Node\\PropertyItem', 'PhpParser\\Node\\Stmt\\StaticVar' => 'PhpParser\\Node\\StaticVar']);
};

View File

@ -0,0 +1 @@
# 0 Rules Overview

View File

@ -0,0 +1,16 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202209;
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();
};

View File

@ -0,0 +1,17 @@
<?php
declare (strict_types=1);
namespace Rector\PhpParser\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class PhpParserSetList implements SetListInterface
{
/**
* @api
* @var string
*/
public const PHP_PARSER_50 = __DIR__ . '/../../config/sets/php-parser-50.php';
}