mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 11:50:51 +00:00
Updated Rector to commit 1a88977444
1a88977444
Bump min PHP to 8, cleanup readmes (#1)
This commit is contained in:
parent
345a89a7e2
commit
b0aab29ab1
211
README.md
211
README.md
|
@ -1,11 +1,88 @@
|
|||
# Prefixed Rector
|
||||
# Rector - Instant Upgrades and Automated Refactoring
|
||||
|
||||
[![Build Status Github Actions](https://img.shields.io/github/workflow/status/rectorphp/rector-prefixed/Code_Checks?style=flat-square)](https://github.com/rectorphp/rector-prefixed/actions)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector-prefixed)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector)
|
||||
|
||||
Do you have conflicts on Rector install? You're in the right place. Prefixed Rector can [be installed even on very old Symfony](https://getrector.org/blog/2020/01/20/how-to-install-rector-despite-composer-conflicts).
|
||||
<br>
|
||||
|
||||
Do you have older PHP? Rector prefixed goes down to PHP 7.1, so you can install it even on older projects.
|
||||
Rector helps you with 2 areas - major code changes and in daily work.
|
||||
|
||||
- Do you have a legacy code base? Do you want to have that latest version of PHP or your favorite framework?
|
||||
→ **Rector gets you there with instant upgrade**.
|
||||
|
||||
<br>
|
||||
|
||||
- Do you have code quality you need, but struggle to keep it with new developers in your team? Do you wish to have code-reviews for each member of your team, but don't have time for it?
|
||||
→ **Add Rector to you CI and let it fix your code for you. Get [instant feedback](https://tomasvotruba.com/blog/2020/01/13/why-is-first-instant-feedback-crucial-to-developers/) after each commit.**
|
||||
|
||||
<br>
|
||||
|
||||
It's a tool that [we develop](https://getrector.org/) and share for free, so anyone can automate their refactoring.
|
||||
|
||||
[Hire us](https://getrector.org/contact) to speed up learning Rector, AST and nodes, to educate your team about Rectors benefits and to setup Rector in your project, so that you can enjoy the 300 % development speed :+1:
|
||||
|
||||
<br>
|
||||
|
||||
## Open-Source First
|
||||
|
||||
Rector **instantly upgrades and refactors the PHP code of your application**.
|
||||
It supports all versions of PHP from 5.3 and major open-source projects:
|
||||
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/php.png">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-phpunit"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/phpunit.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-symfony"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/symfony.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/palantirnet/drupal-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/drupal.png" alt="Drupal Rector rules">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
<br>
|
||||
<a href="https://github.com/rectorphp/rector-cakephp"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/cakephp.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/sabbelasichon/typo3-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/typo3.png">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
</p>
|
||||
|
||||
### What Can Rector Do for You?
|
||||
|
||||
- [Complete 2800 `@var` types in 2 minutes](https://tomasvotruba.com/blog/2019/07/29/how-we-completed-thousands-of-missing-var-annotations-in-a-day/)
|
||||
- [Upgrade 30 000 unit tests from PHPUnit 6 to 9](https://twitter.com/LBajsarowicz/status/1272947900016967683)
|
||||
- [Complete PHP 7.4 Property Types](https://tomasvotruba.com/blog/2018/11/15/how-to-get-php-74-typed-properties-to-your-code-in-few-seconds/)
|
||||
- [Migrate from Nette to Symfony](https://tomasvotruba.com/blog/2019/02/21/how-we-migrated-from-nette-to-symfony-in-3-weeks-part-1/)
|
||||
- [Refactor Laravel Facades to Dependency Injection](https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/)
|
||||
- And much more...
|
||||
|
||||
<br>
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Explore 450+ Rector Rules](/docs/rector_rules_overview.md)
|
||||
- [How Does Rector Work?](/docs/how_it_works.md)
|
||||
- [PHP Parser Nodes](https://github.com/rectorphp/php-parser-nodes-docs/)
|
||||
|
||||
### Advanced
|
||||
|
||||
- [Auto Import Names](/docs/auto_import_names.md)
|
||||
- [How to Ignore Rule or Paths](/docs/how_to_ignore_rule_or_paths.md)
|
||||
- [Static Reflection and Autoload](/docs/static_reflection_and_autoload.md)
|
||||
- [How to Configure Rule](/docs/how_to_configure_rules.md)
|
||||
- [How to Generate Configuration file](/docs/init_command.md)
|
||||
|
||||
### Contributing
|
||||
|
||||
- [How to add Test for Rector Rule](/docs/how_to_add_test_for_rector_rule.md)
|
||||
- [How to work with Doc Block and Comments](/docs/how_to_work_with_doc_block_and_comments.md)
|
||||
- [How to Create New Rector Rule](/docs/create_own_rule.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -13,13 +90,131 @@ Do you have older PHP? Rector prefixed goes down to PHP 7.1, so you can install
|
|||
composer require rector/rector --dev
|
||||
```
|
||||
|
||||
- Having conflicts during `composer require`? → Use the [Rector Prefixed](https://github.com/rectorphp/rector-prefixed) with PHP 7.1+ version
|
||||
- Using a different PHP version than Rector supports? → Use the [Docker image](/docs/how_to_run_rector_in_docker.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Running Rector
|
||||
|
||||
There a 2 main ways to use Rector:
|
||||
|
||||
- a *single rule*, to have the change under control
|
||||
- or group of rules called *sets*
|
||||
|
||||
To use them, create a `rector.php` in your root directory:
|
||||
|
||||
```bash
|
||||
# generate "rector.php" config
|
||||
vendor/bin/rector init
|
||||
```
|
||||
|
||||
# dry run
|
||||
And modify it:
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// here we can define, what sets of rules will be applied
|
||||
// tip: use "SetList" class to autocomplete sets
|
||||
$containerConfigurator->import(SetList::CODE_QUALITY);
|
||||
|
||||
// register single rule
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class);
|
||||
};
|
||||
```
|
||||
|
||||
Then dry run Rector:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src --dry-run
|
||||
```
|
||||
|
||||
# changing run
|
||||
Rector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src
|
||||
```
|
||||
|
||||
*Note: `rector.php` is loaded by default. For different location, use `--config` option.*
|
||||
|
||||
<br>
|
||||
|
||||
## Configuration
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// paths to refactor; solid alternative to CLI arguments
|
||||
$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
|
||||
// is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
|
||||
|
||||
// Run Rector only on changed files
|
||||
$parameters->set(Option::ENABLE_CACHE, true);
|
||||
|
||||
// Path to phpstan with extensions, that PHPSTan in Rector uses to determine types
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan-for-config.neon');
|
||||
};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## How to Contribute
|
||||
|
||||
See [the contribution guide](/CONTRIBUTING.md).
|
||||
|
||||
<br>
|
||||
|
||||
### Debugging
|
||||
|
||||
You can use `--debug` option, that will print nested exceptions output:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --debug
|
||||
```
|
||||
|
||||
Or with Xdebug:
|
||||
|
||||
1. Make sure [Xdebug](https://xdebug.org/) is installed and configured
|
||||
2. Add `--xdebug` option when running Rector
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --xdebug
|
||||
```
|
||||
|
||||
To assist with simple debugging Rector provides a 2 helpers to pretty-print AST-nodes:
|
||||
|
||||
```php
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
|
||||
$node = new String_('hello world!');
|
||||
|
||||
// prints node to string, as PHP code displays it
|
||||
print_node($node);
|
||||
|
||||
// dump nested node object with nested properties
|
||||
dump_node($node);
|
||||
// 2nd argument is how deep the nesting is - this makes sure the dump is short and useful
|
||||
dump_node($node, 1);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Known Drawbacks
|
||||
|
||||
### How to Apply Coding Standards?
|
||||
|
||||
Rector uses [nikic/php-parser](https://github.com/nikic/PHP-Parser/), built on technology called an *abstract syntax tree* (AST). An AST doesn't know about spaces and when written to a file it produces poorly formatted code in both PHP and docblock annotations. **That's why your project needs to have a coding standard tool** and a set of formatting rules, so it can make Rector's output code nice and shiny again.
|
||||
|
||||
We're using [ECS](https://github.com/symplify/easy-coding-standard) with [this setup](ecs.php).
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea::getLoader();
|
||||
return ComposerAutoloaderInit2e688caaf56ef6b168cbe38fed24d74d::getLoader();
|
||||
|
|
2
vendor/composer/InstalledVersions.php
vendored
2
vendor/composer/InstalledVersions.php
vendored
File diff suppressed because one or more lines are too long
4
vendor/composer/autoload_files.php
vendored
4
vendor/composer/autoload_files.php
vendored
|
@ -14,12 +14,10 @@ return array(
|
|||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
'd507e002f7fce7f0c6dbf1f22edcb902' => $vendorDir . '/tracy/tracy/src/Tracy/functions.php',
|
||||
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
|
||||
'65fec9ebcfbb3cbb4fd0d519687aea01' => $vendorDir . '/danielstjules/stringy/src/Create.php',
|
||||
'923d539a1f533edc0b2cba94a01b02b2' => $vendorDir . '/rector/rector/src/functions/node_helper.php',
|
||||
'dab4fb23683ef7ffaa691f2923bbaba3' => $vendorDir . '/rector/rector/src/constants.php',
|
||||
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
|
||||
'65fec9ebcfbb3cbb4fd0d519687aea01' => $vendorDir . '/danielstjules/stringy/src/Create.php',
|
||||
'30bca7fff093e8069bed7c55247e2bf8' => $baseDir . '/src/functions/node_helper.php',
|
||||
'4508688f3cab21375725e8d11ca194a2' => $baseDir . '/src/constants.php',
|
||||
);
|
||||
|
|
6
vendor/composer/autoload_psr4.php
vendored
6
vendor/composer/autoload_psr4.php
vendored
|
@ -15,10 +15,10 @@ return array(
|
|||
'Rector\\NetteToSymfony\\' => array($vendorDir . '/rector/rector-nette-to-symfony/src'),
|
||||
'Rector\\Laravel\\' => array($vendorDir . '/rector/rector-laravel/src'),
|
||||
'Rector\\Doctrine\\' => array($vendorDir . '/rector/rector-doctrine/src'),
|
||||
'Rector\\Core\\' => array($baseDir . '/src', $vendorDir . '/rector/rector/src'),
|
||||
'Rector\\Compiler\\' => array($baseDir . '/utils/compiler/src', $vendorDir . '/rector/rector/utils/compiler/src'),
|
||||
'Rector\\Core\\' => array($baseDir . '/src'),
|
||||
'Rector\\Compiler\\' => array($baseDir . '/utils/compiler/src'),
|
||||
'Rector\\CakePHP\\' => array($vendorDir . '/rector/rector-cakephp/src'),
|
||||
'Rector\\' => array($baseDir . '/packages', $baseDir . '/rules', $vendorDir . '/rector/rector/packages', $vendorDir . '/rector/rector/rules'),
|
||||
'Rector\\' => array($baseDir . '/packages', $baseDir . '/rules'),
|
||||
'RectorPrefix20210510\\Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
|
||||
'RectorPrefix20210510\\Symplify\\SymplifyKernel\\' => array($vendorDir . '/symplify/symplify-kernel/src'),
|
||||
'RectorPrefix20210510\\Symplify\\SmartFileSystem\\' => array($vendorDir . '/symplify/smart-file-system/src'),
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea
|
||||
class ComposerAutoloaderInit2e688caaf56ef6b168cbe38fed24d74d
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2e688caaf56ef6b168cbe38fed24d74d', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2e688caaf56ef6b168cbe38fed24d74d', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit86112f24530f6ee67d6d285973b2d5ea
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire86112f24530f6ee67d6d285973b2d5ea($fileIdentifier, $file);
|
||||
composerRequire2e688caaf56ef6b168cbe38fed24d74d($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire86112f24530f6ee67d6d285973b2d5ea($fileIdentifier, $file)
|
||||
function composerRequire2e688caaf56ef6b168cbe38fed24d74d($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
16
vendor/composer/autoload_static.php
vendored
16
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea
|
||||
class ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -15,12 +15,10 @@ class ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea
|
|||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
'd507e002f7fce7f0c6dbf1f22edcb902' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/functions.php',
|
||||
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
|
||||
'65fec9ebcfbb3cbb4fd0d519687aea01' => __DIR__ . '/..' . '/danielstjules/stringy/src/Create.php',
|
||||
'923d539a1f533edc0b2cba94a01b02b2' => __DIR__ . '/..' . '/rector/rector/src/functions/node_helper.php',
|
||||
'dab4fb23683ef7ffaa691f2923bbaba3' => __DIR__ . '/..' . '/rector/rector/src/constants.php',
|
||||
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
|
||||
'65fec9ebcfbb3cbb4fd0d519687aea01' => __DIR__ . '/..' . '/danielstjules/stringy/src/Create.php',
|
||||
'30bca7fff093e8069bed7c55247e2bf8' => __DIR__ . '/../..' . '/src/functions/node_helper.php',
|
||||
'4508688f3cab21375725e8d11ca194a2' => __DIR__ . '/../..' . '/src/constants.php',
|
||||
);
|
||||
|
@ -138,12 +136,10 @@ class ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea
|
|||
'Rector\\Core\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../..' . '/src',
|
||||
1 => __DIR__ . '/..' . '/rector/rector/src',
|
||||
),
|
||||
'Rector\\Compiler\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../..' . '/utils/compiler/src',
|
||||
1 => __DIR__ . '/..' . '/rector/rector/utils/compiler/src',
|
||||
),
|
||||
'Rector\\CakePHP\\' =>
|
||||
array (
|
||||
|
@ -153,8 +149,6 @@ class ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea
|
|||
array (
|
||||
0 => __DIR__ . '/../..' . '/packages',
|
||||
1 => __DIR__ . '/../..' . '/rules',
|
||||
2 => __DIR__ . '/..' . '/rector/rector/packages',
|
||||
3 => __DIR__ . '/..' . '/rector/rector/rules',
|
||||
),
|
||||
'RectorPrefix20210510\\Webmozart\\Assert\\' =>
|
||||
array (
|
||||
|
@ -3471,9 +3465,9 @@ class ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit86112f24530f6ee67d6d285973b2d5ea::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2e688caaf56ef6b168cbe38fed24d74d::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
119
vendor/composer/installed.json
vendored
119
vendor/composer/installed.json
vendored
|
@ -1308,125 +1308,6 @@
|
|||
},
|
||||
"install-path": "..\/rector\/extension-installer"
|
||||
},
|
||||
{
|
||||
"name": "rector\/rector",
|
||||
"version": "0.10.21",
|
||||
"version_normalized": "0.10.21.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector.git",
|
||||
"reference": "dd41106ee4f97c64019a5dc0fd4142c9a2980f89"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector\/zipball\/dd41106ee4f97c64019a5dc0fd4142c9a2980f89",
|
||||
"reference": "dd41106ee4f97c64019a5dc0fd4142c9a2980f89",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer\/semver": "^3.2",
|
||||
"composer\/xdebug-handler": "^1.3|^2.0",
|
||||
"danielstjules\/stringy": "^3.1",
|
||||
"doctrine\/inflector": "^2.0",
|
||||
"ergebnis\/json-printer": "^3.1",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"idiosyncratic\/editorconfig": "^0.1.0",
|
||||
"jean85\/pretty-package-versions": "^1.6",
|
||||
"nette\/caching": "^3.1",
|
||||
"nette\/utils": "^3.2",
|
||||
"nikic\/php-parser": "4.10.4",
|
||||
"php": "^7.3|^8.0",
|
||||
"phpstan\/phpdoc-parser": "^0.5.4",
|
||||
"phpstan\/phpstan": "0.12.85",
|
||||
"phpstan\/phpstan-phpunit": "^0.12.18",
|
||||
"rector\/extension-installer": "^0.10.2",
|
||||
"rector\/rector-cakephp": "^0.10.4",
|
||||
"rector\/rector-doctrine": "^0.10.6",
|
||||
"rector\/rector-laravel": "^0.10.2",
|
||||
"rector\/rector-nette": "^0.10.9",
|
||||
"rector\/rector-nette-to-symfony": "^0.10.0",
|
||||
"rector\/rector-phpunit": "^0.10.8",
|
||||
"rector\/rector-symfony": "^0.10.5",
|
||||
"sebastian\/diff": "^4.0.4",
|
||||
"shanethehat\/pretty-xml": "^1.0",
|
||||
"symfony\/console": "^4.4.8|^5.1",
|
||||
"symfony\/dependency-injection": "^5.1",
|
||||
"symfony\/finder": "^4.4.8|^5.1",
|
||||
"symfony\/http-kernel": "^4.4.8|^5.1",
|
||||
"symplify\/astral": "^9.3",
|
||||
"symplify\/autowire-array-parameter": "^9.3",
|
||||
"symplify\/console-color-diff": "^9.3",
|
||||
"symplify\/package-builder": "^9.3",
|
||||
"symplify\/rule-doc-generator-contracts": "^9.3",
|
||||
"symplify\/set-config-resolver": "^9.3",
|
||||
"symplify\/simple-php-doc-parser": "^9.3",
|
||||
"symplify\/skipper": "^9.3",
|
||||
"symplify\/smart-file-system": "^9.3",
|
||||
"symplify\/symfony-php-config": "^9.3",
|
||||
"tracy\/tracy": "^2.8",
|
||||
"webmozart\/assert": "^1.10"
|
||||
},
|
||||
"replace": {
|
||||
"rector\/rector-prefixed": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpstan\/phpstan-nette": "^0.12.16",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/rector-generator": "^0.1.7",
|
||||
"rector\/rector-phpstan-rules": "^0.1",
|
||||
"symplify\/coding-standard": "^9.3",
|
||||
"symplify\/easy-ci": "^9.3",
|
||||
"symplify\/easy-coding-standard": "^9.3",
|
||||
"symplify\/easy-testing": "^9.3",
|
||||
"symplify\/phpstan-extensions": "^9.3",
|
||||
"symplify\/phpstan-rules": "^9.3",
|
||||
"symplify\/rule-doc-generator": "^9.3"
|
||||
},
|
||||
"time": "2021-05-09T00:15:50+00:00",
|
||||
"bin": [
|
||||
"bin\/rector"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\": [
|
||||
"packages",
|
||||
"rules"
|
||||
],
|
||||
"Rector\\Core\\": "src",
|
||||
"Rector\\Compiler\\": "utils\/compiler\/src"
|
||||
},
|
||||
"files": [
|
||||
"src\/functions\/node_helper.php",
|
||||
"src\/constants.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Instant upgrade and refactoring of your PHP code",
|
||||
"homepage": "https:\/\/getrector.org",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector\/tree\/0.10.21"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https:\/\/github.com\/tomasvotruba",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"install-path": "..\/rector\/rector"
|
||||
},
|
||||
{
|
||||
"name": "rector\/rector-cakephp",
|
||||
"version": "0.10.4",
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
25
vendor/rector/rector/LICENSE
vendored
25
vendor/rector/rector/LICENSE
vendored
|
@ -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.
|
220
vendor/rector/rector/README.md
vendored
220
vendor/rector/rector/README.md
vendored
|
@ -1,220 +0,0 @@
|
|||
# Rector - Speedup Your PHP Development
|
||||
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector)
|
||||
|
||||
<br>
|
||||
|
||||
Rector helps you with 2 areas - major code changes and in daily work.
|
||||
|
||||
- Do you have a legacy code base? Do you want to have that latest version of PHP or your favorite framework?
|
||||
→ **Rector gets you there with instant upgrade**.
|
||||
|
||||
<br>
|
||||
|
||||
- Do you have code quality you need, but struggle to keep it with new developers in your team? Do you wish to have code-reviews for each member of your team, but don't have time for it?
|
||||
→ **Add Rector to you CI and let it fix your code for you. Get [instant feedback](https://tomasvotruba.com/blog/2020/01/13/why-is-first-instant-feedback-crucial-to-developers/) after each commit.**
|
||||
|
||||
<br>
|
||||
|
||||
It's a tool that [we develop](https://getrector.org/) and share for free, so anyone can automate their refactoring.
|
||||
|
||||
[Hire us](https://getrector.org/contact) to speed up learning Rector, AST and nodes, to educate your team about Rectors benefits and to setup Rector in your project, so that you can enjoy the 300 % development speed :+1:
|
||||
|
||||
<br>
|
||||
|
||||
## Open-Source First
|
||||
|
||||
Rector **instantly upgrades and refactors the PHP code of your application**.
|
||||
It supports all versions of PHP from 5.3 and major open-source projects:
|
||||
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/php.png">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-phpunit"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/phpunit.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-symfony"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/symfony.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/palantirnet/drupal-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/drupal.png" alt="Drupal Rector rules">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
<br>
|
||||
<a href="https://github.com/rectorphp/rector-cakephp"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/cakephp.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/sabbelasichon/typo3-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/typo3.png">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
</p>
|
||||
|
||||
### What Can Rector Do for You?
|
||||
|
||||
- [Complete 2800 `@var` types in 2 minutes](https://tomasvotruba.com/blog/2019/07/29/how-we-completed-thousands-of-missing-var-annotations-in-a-day/)
|
||||
- [Upgrade 30 000 unit tests from PHPUnit 6 to 9](https://twitter.com/LBajsarowicz/status/1272947900016967683)
|
||||
- [Complete PHP 7.4 Property Types](https://tomasvotruba.com/blog/2018/11/15/how-to-get-php-74-typed-properties-to-your-code-in-few-seconds/)
|
||||
- [Migrate from Nette to Symfony](https://tomasvotruba.com/blog/2019/02/21/how-we-migrated-from-nette-to-symfony-in-3-weeks-part-1/)
|
||||
- [Refactor Laravel Facades to Dependency Injection](https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/)
|
||||
- And much more...
|
||||
|
||||
<br>
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Explore 450+ Rector Rules](/docs/rector_rules_overview.md)
|
||||
- [How Does Rector Work?](/docs/how_it_works.md)
|
||||
- [PHP Parser Nodes](https://github.com/rectorphp/php-parser-nodes-docs/)
|
||||
|
||||
### Advanced
|
||||
|
||||
- [Auto Import Names](/docs/auto_import_names.md)
|
||||
- [How to Ignore Rule or Paths](/docs/how_to_ignore_rule_or_paths.md)
|
||||
- [Static Reflection and Autoload](/docs/static_reflection_and_autoload.md)
|
||||
- [How to Configure Rule](/docs/how_to_configure_rules.md)
|
||||
- [How to Generate Configuration file](/docs/init_command.md)
|
||||
|
||||
### Contributing
|
||||
|
||||
- [How to add Test for Rector Rule](/docs/how_to_add_test_for_rector_rule.md)
|
||||
- [How to work with Doc Block and Comments](/docs/how_to_work_with_doc_block_and_comments.md)
|
||||
- [How to Create New Rector Rule](/docs/create_own_rule.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
composer require rector/rector --dev
|
||||
```
|
||||
|
||||
- Having conflicts during `composer require`? → Use the [Rector Prefixed](https://github.com/rectorphp/rector-prefixed) with PHP 7.1+ version
|
||||
- Using a different PHP version than Rector supports? → Use the [Docker image](/docs/how_to_run_rector_in_docker.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Running Rector
|
||||
|
||||
There a 2 main ways to use Rector:
|
||||
|
||||
- a *single rule*, to have the change under control
|
||||
- or group of rules called *sets*
|
||||
|
||||
To use them, create a `rector.php` in your root directory:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector init
|
||||
```
|
||||
|
||||
And modify it:
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// here we can define, what sets of rules will be applied
|
||||
// tip: use "SetList" class to autocomplete sets
|
||||
$containerConfigurator->import(SetList::CODE_QUALITY);
|
||||
|
||||
// register single rule
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class);
|
||||
};
|
||||
```
|
||||
|
||||
Then dry run Rector:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src --dry-run
|
||||
```
|
||||
|
||||
Rector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src
|
||||
```
|
||||
|
||||
*Note: `rector.php` is loaded by default. For different location, use `--config` option.*
|
||||
|
||||
<br>
|
||||
|
||||
## Configuration
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// paths to refactor; solid alternative to CLI arguments
|
||||
$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
|
||||
// is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
|
||||
|
||||
// Run Rector only on changed files
|
||||
$parameters->set(Option::ENABLE_CACHE, true);
|
||||
|
||||
// Path to phpstan with extensions, that PHPSTan in Rector uses to determine types
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan-for-config.neon');
|
||||
};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## How to Contribute
|
||||
|
||||
See [the contribution guide](/CONTRIBUTING.md).
|
||||
|
||||
<br>
|
||||
|
||||
### Debugging
|
||||
|
||||
You can use `--debug` option, that will print nested exceptions output:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --debug
|
||||
```
|
||||
|
||||
Or with Xdebug:
|
||||
|
||||
1. Make sure [Xdebug](https://xdebug.org/) is installed and configured
|
||||
2. Add `--xdebug` option when running Rector
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --xdebug
|
||||
```
|
||||
|
||||
To assist with simple debugging Rector provides a 2 helpers to pretty-print AST-nodes:
|
||||
|
||||
```php
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
|
||||
$node = new String_('hello world!');
|
||||
|
||||
// prints node to string, as PHP code displays it
|
||||
print_node($node);
|
||||
|
||||
// dump nested node object with nested properties
|
||||
dump_node($node);
|
||||
// 2nd argument is how deep the nesting is - this makes sure the dump is short and useful
|
||||
dump_node($node, 1);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Known Drawbacks
|
||||
|
||||
### How to Apply Coding Standards?
|
||||
|
||||
Rector uses [nikic/php-parser](https://github.com/nikic/PHP-Parser/), built on technology called an *abstract syntax tree* (AST). An AST doesn't know about spaces and when written to a file it produces poorly formatted code in both PHP and docblock annotations. **That's why your project needs to have a coding standard tool** and a set of formatting rules, so it can make Rector's output code nice and shiny again.
|
||||
|
||||
We're using [ECS](https://github.com/symplify/easy-coding-standard) with [this setup](ecs.php).
|
127
vendor/rector/rector/UPGRADE.md
vendored
127
vendor/rector/rector/UPGRADE.md
vendored
|
@ -1,127 +0,0 @@
|
|||
# How to Upgrade from Rector 0.9 to 0.10 (2021-03)
|
||||
|
||||
Use prepare Rector set to upgrade your code:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src --config vendor/rector/rector/upgrade/rector_010.php
|
||||
```
|
||||
|
||||
Some changes have to be handled manually:
|
||||
|
||||
## In Symfony project, clear `config/bundles.php`
|
||||
|
||||
- drop `PhpConfigPrinterBundle` class
|
||||
|
||||
## Removed Attributes
|
||||
|
||||
- `getAttribute(AttributeKey::PARENT_CLASS_NAME)` → use `$scope->getClassReflection()` instead
|
||||
- `getAttribute(AttributeKey::NAMESPACE_NAME)` → use `$scope->getNamespace()` instead
|
||||
- `getAttribute(AttributeKey::NAMESPACE_NODE)` → use `$scope->getNamespace()` instead
|
||||
|
||||
<br>
|
||||
|
||||
# How to Upgrade From Rector 0.8 to 0.9 (2020-12)
|
||||
|
||||
## In Symfony project, clear `config/bundles.php`
|
||||
|
||||
- drop `ComposerJsonManipulatorBundle` class
|
||||
- drop `ConsoleColorDiffBundle` class
|
||||
|
||||
## Set Consolidation
|
||||
|
||||
Sets with ambiguous naming were removed and rules moved to proper-named sets:
|
||||
|
||||
```diff
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::SETS, [
|
||||
- SetList::SOLID,
|
||||
+ SetList::CODING_STYLE,
|
||||
- SetList::PHPSTAN,
|
||||
+ SetList::PRIVATIZATION,
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
## Single `SKIP` option `rector.php`
|
||||
|
||||
Since Rector 0.9 we switched from internal skipping to [`symplify/skipper` package](https://tomasvotruba.com/blog/2020/12/10/new-in-symplify-9-skipper-skipping-files-and-rules-made-simple/). Now there is only one `Option::SKIP` parameter to handle both paths and classes.
|
||||
|
||||
Replace deprecated `Option::EXCLUDE_RECTORS` parameters with `Option::SKIP`:
|
||||
|
||||
```diff
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
- $parameters->set(Option::EXCLUDE_RECTORS, [
|
||||
+ $parameters->set(Option::SKIP, [
|
||||
SomeRector::class,
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
Replace deprecated `Option::EXCLUDE_PATHS` parameters with `Option::SKIP`:
|
||||
|
||||
```diff
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
- $parameters->set(Option::EXCLUDE_PATHS, [
|
||||
+ $parameters->set(Option::SKIP, [
|
||||
__DIR__ . '/SomePath,
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
Be sure to have **exactly 1** `Option::SKIP` in the end, as the Symfony parameters are not merged, but overridden:
|
||||
|
||||
```diff
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::SKIP, [
|
||||
SomeRector::class,
|
||||
- ]);
|
||||
-
|
||||
- $parameters->set(Option::SKIP, [
|
||||
__DIR__ . '/SomePath,
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
## From CLI `--set`/`--level` to config
|
||||
|
||||
Rector now works more and more with set stacking. The number of sets is growing and IDE autocomplete helps to work with them effectively. If you use these options in CLI, move them to `rector.php` config like this:
|
||||
|
||||
```diff
|
||||
-vendor/bin/rector process src --set php80
|
||||
+vendor/bin/rector process src
|
||||
```
|
||||
|
||||
```diff
|
||||
use Rector\Core\Configuration\Option;
|
||||
+use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::SETS, [
|
||||
+ SetList::PHP_80,
|
||||
]);
|
||||
};
|
||||
```
|
5
vendor/rector/rector/bin/rector
vendored
5
vendor/rector/rector/bin/rector
vendored
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
require_once __DIR__ . '/rector.php';
|
114
vendor/rector/rector/bin/rector.php
vendored
114
vendor/rector/rector/bin/rector.php
vendored
|
@ -1,114 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Bootstrap\RectorConfigsResolver;
|
||||
use Rector\Core\Console\ConsoleApplication;
|
||||
use Rector\Core\Console\Style\SymfonyStyleFactory;
|
||||
use Rector\Core\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Console\ShellCode;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
// @ intentionally: continue anyway
|
||||
@\ini_set('memory_limit', '-1');
|
||||
// Performance boost
|
||||
\error_reporting(\E_ALL);
|
||||
\ini_set('display_errors', 'stderr');
|
||||
\gc_disable();
|
||||
\define('__RECTOR_RUNNING__', \true);
|
||||
// Require Composer autoload.php
|
||||
$autoloadIncluder = new \RectorPrefix20210510\AutoloadIncluder();
|
||||
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
||||
// load extracted PHPStan with its own preload.php
|
||||
$extractedPhpstanAutoload = __DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php';
|
||||
if (\file_exists($extractedPhpstanAutoload)) {
|
||||
require_once $extractedPhpstanAutoload;
|
||||
} elseif (\RectorPrefix20210510\should_include_preload()) {
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
}
|
||||
require_once __DIR__ . '/../src/constants.php';
|
||||
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
|
||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||
$autoloadIncluder->autoloadFromCommandLine();
|
||||
$symfonyStyleFactory = new \Rector\Core\Console\Style\SymfonyStyleFactory(new \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller());
|
||||
$symfonyStyle = $symfonyStyleFactory->create();
|
||||
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
|
||||
try {
|
||||
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
||||
$rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory();
|
||||
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
||||
} catch (\Throwable $throwable) {
|
||||
$symfonyStyle->error($throwable->getMessage());
|
||||
exit(\RectorPrefix20210510\Symplify\PackageBuilder\Console\ShellCode::ERROR);
|
||||
}
|
||||
// preload local InstalledVersions.php - to fix incorrect version by same-named class in phpstan
|
||||
$currentlyInstalledVersions = __DIR__ . '/../../../../vendor/composer/InstalledVersions.php';
|
||||
if (\file_exists($currentlyInstalledVersions)) {
|
||||
require_once $currentlyInstalledVersions;
|
||||
}
|
||||
/** @var ConsoleApplication $application */
|
||||
$application = $container->get(\Rector\Core\Console\ConsoleApplication::class);
|
||||
exit($application->run());
|
||||
final class AutoloadIncluder
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $alreadyLoadedAutoloadFiles = [];
|
||||
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
|
||||
{
|
||||
// Rector's vendor is already loaded
|
||||
if (\class_exists(\Rector\Core\HttpKernel\RectorKernel::class)) {
|
||||
return;
|
||||
}
|
||||
// in Rector develop repository
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/autoload.php');
|
||||
}
|
||||
/**
|
||||
* In case Rector is installed as vendor dependency,
|
||||
* this autoloads the project vendor/autoload.php, including Rector
|
||||
*/
|
||||
public function autoloadProjectAutoloaderFile() : void
|
||||
{
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../../autoload.php');
|
||||
}
|
||||
public function autoloadFromCommandLine() : void
|
||||
{
|
||||
$cliArgs = $_SERVER['argv'];
|
||||
$autoloadOptionPosition = \array_search('-a', $cliArgs, \true) ?: \array_search('--autoload-file', $cliArgs, \true);
|
||||
if (!$autoloadOptionPosition) {
|
||||
return;
|
||||
}
|
||||
$autoloadFileValuePosition = $autoloadOptionPosition + 1;
|
||||
$fileToAutoload = $cliArgs[$autoloadFileValuePosition] ?? null;
|
||||
if ($fileToAutoload === null) {
|
||||
return;
|
||||
}
|
||||
$this->loadIfExistsAndNotLoadedYet($fileToAutoload);
|
||||
}
|
||||
public function loadIfExistsAndNotLoadedYet(string $filePath) : void
|
||||
{
|
||||
if (!\file_exists($filePath)) {
|
||||
return;
|
||||
}
|
||||
if (\in_array($filePath, $this->alreadyLoadedAutoloadFiles, \true)) {
|
||||
return;
|
||||
}
|
||||
$this->alreadyLoadedAutoloadFiles[] = \realpath($filePath);
|
||||
require_once $filePath;
|
||||
}
|
||||
}
|
||||
\class_alias('RectorPrefix20210510\\AutoloadIncluder', 'AutoloadIncluder', \false);
|
||||
// load local php-parser only in prefixed version or development repository
|
||||
function should_include_preload() : bool
|
||||
{
|
||||
if (\file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
|
||||
return \true;
|
||||
}
|
||||
if (!\file_exists(\getcwd() . '/composer.json')) {
|
||||
return \false;
|
||||
}
|
||||
$composerJsonFileContent = \file_get_contents(\getcwd() . '/composer.json');
|
||||
return \strpos($composerJsonFileContent, '"name": "rector/rector"') !== \false;
|
||||
}
|
144
vendor/rector/rector/composer.json
vendored
144
vendor/rector/rector/composer.json
vendored
|
@ -1,144 +0,0 @@
|
|||
{
|
||||
"name": "rector\/rector",
|
||||
"description": "Instant upgrade and refactoring of your PHP code",
|
||||
"bin": [
|
||||
"bin\/rector"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https:\/\/getrector.org",
|
||||
"require": {
|
||||
"php": "^7.3|^8.0",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"composer\/semver": "^3.2",
|
||||
"composer\/xdebug-handler": "^1.3|^2.0",
|
||||
"danielstjules\/stringy": "^3.1",
|
||||
"doctrine\/inflector": "^2.0",
|
||||
"ergebnis\/json-printer": "^3.1",
|
||||
"idiosyncratic\/editorconfig": "^0.1.0",
|
||||
"jean85\/pretty-package-versions": "^1.6",
|
||||
"nette\/caching": "^3.1",
|
||||
"nette\/utils": "^3.2",
|
||||
"nikic\/php-parser": "4.10.4",
|
||||
"phpstan\/phpdoc-parser": "^0.5.4",
|
||||
"phpstan\/phpstan": "0.12.85",
|
||||
"phpstan\/phpstan-phpunit": "^0.12.18",
|
||||
"rector\/rector-cakephp": "^0.10.4",
|
||||
"rector\/rector-doctrine": "^0.10.6",
|
||||
"rector\/extension-installer": "^0.10.2",
|
||||
"rector\/rector-laravel": "^0.10.2",
|
||||
"rector\/rector-nette": "^0.10.9",
|
||||
"rector\/rector-nette-to-symfony": "^0.10.0",
|
||||
"rector\/rector-phpunit": "^0.10.8",
|
||||
"rector\/rector-symfony": "^0.10.5",
|
||||
"sebastian\/diff": "^4.0.4",
|
||||
"shanethehat\/pretty-xml": "^1.0",
|
||||
"symfony\/console": "^4.4.8|^5.1",
|
||||
"symfony\/dependency-injection": "^5.1",
|
||||
"symfony\/finder": "^4.4.8|^5.1",
|
||||
"symfony\/http-kernel": "^4.4.8|^5.1",
|
||||
"symplify\/astral": "^9.3",
|
||||
"symplify\/autowire-array-parameter": "^9.3",
|
||||
"symplify\/console-color-diff": "^9.3",
|
||||
"symplify\/package-builder": "^9.3",
|
||||
"symplify\/rule-doc-generator-contracts": "^9.3",
|
||||
"symplify\/set-config-resolver": "^9.3",
|
||||
"symplify\/simple-php-doc-parser": "^9.3",
|
||||
"symplify\/skipper": "^9.3",
|
||||
"symplify\/smart-file-system": "^9.3",
|
||||
"symplify\/symfony-php-config": "^9.3",
|
||||
"tracy\/tracy": "^2.8",
|
||||
"webmozart\/assert": "^1.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpstan\/phpstan-nette": "^0.12.16",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/rector-generator": "^0.1.7",
|
||||
"rector\/rector-phpstan-rules": "^0.1",
|
||||
"symplify\/coding-standard": "^9.3",
|
||||
"symplify\/easy-ci": "^9.3",
|
||||
"symplify\/easy-coding-standard": "^9.3",
|
||||
"symplify\/easy-testing": "^9.3",
|
||||
"symplify\/phpstan-extensions": "^9.3",
|
||||
"symplify\/phpstan-rules": "^9.3",
|
||||
"symplify\/rule-doc-generator": "^9.3"
|
||||
},
|
||||
"replace": {
|
||||
"rector\/rector-prefixed": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\": [
|
||||
"packages",
|
||||
"rules"
|
||||
],
|
||||
"Rector\\Core\\": "src",
|
||||
"Rector\\Compiler\\": "utils\/compiler\/src"
|
||||
},
|
||||
"files": [
|
||||
"src\/functions\/node_helper.php",
|
||||
"src\/constants.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Rector\\Tests\\": [
|
||||
"packages-tests",
|
||||
"rules-tests"
|
||||
],
|
||||
"Rector\\Core\\Tests\\": "tests",
|
||||
"Rector\\RuleDocGenerator\\": "utils\/rule-doc-generator\/src"
|
||||
},
|
||||
"classmap": [
|
||||
"stubs\/Annotations",
|
||||
"stubs\/Nette",
|
||||
"rules-tests\/Autodiscovery\/Rector\/Class_\/MoveServicesBySuffixToDirectoryRector\/Expected",
|
||||
"rules-tests\/Autodiscovery\/Rector\/Interface_\/MoveInterfacesToContractNamespaceDirectoryRector\/Expected",
|
||||
"rules-tests\/CodingStyle\/Rector\/Namespace_\/ImportFullyQualifiedNamesRector\/Source",
|
||||
"rules-tests\/Renaming\/Rector\/Name\/RenameClassRector\/Source",
|
||||
"rules-tests\/Renaming\/Rector\/FileWithoutNamespace\/PseudoNamespaceToNamespaceRector\/Source",
|
||||
"rules-tests\/CodingStyle\/Rector\/Namespace_\/ImportFullyQualifiedNamesRector\/Source",
|
||||
"rules-tests\/Renaming\/Rector\/Name\/RenameClassRector\/Source"
|
||||
],
|
||||
"files": [
|
||||
"stubs\/Doctrine\/Persistence\/ObjectManager.php",
|
||||
"stubs\/Doctrine\/Common\/Persistence\/ObjectManager.php",
|
||||
"rules-tests\/Transform\/Rector\/FuncCall\/FuncCallToMethodCallRector\/Source\/some_view_function.php",
|
||||
"rules-tests\/TypeDeclaration\/Rector\/FunctionLike\/ReturnTypeDeclarationRector\/Source\/MyBar.php",
|
||||
"rules-tests\/TypeDeclaration\/Rector\/Property\/CompleteVarDocTypePropertyRector\/Source\/EventDispatcher.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"complete-check": [
|
||||
"@check-cs",
|
||||
"@phpstan",
|
||||
"@docs",
|
||||
"phpunit"
|
||||
],
|
||||
"check-cs": [
|
||||
"vendor\/bin\/ecs check --ansi",
|
||||
"vendor\/bin\/ecs check-markdown README.md --ansi"
|
||||
],
|
||||
"fix-cs": [
|
||||
"vendor\/bin\/ecs check --fix --ansi",
|
||||
"vendor\/bin\/ecs check-markdown README.md --fix --ansi"
|
||||
],
|
||||
"phpstan": "vendor\/bin\/phpstan analyse --ansi --error-format symplify",
|
||||
"phpstan-config": "vendor\/bin\/phpstan analyse config --ansi --error-format symplify",
|
||||
"docs": [
|
||||
"vendor\/bin\/rule-doc-generator generate packages rules --output-file docs\/rector_rules_overview.md --ansi --categorize",
|
||||
"vendor\/bin\/ecs check-markdown docs\/rector_rules_overview.md --ansi --fix"
|
||||
],
|
||||
"rector": "bin\/rector process --ansi"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"platform-check": false
|
||||
}
|
||||
}
|
24
vendor/rector/rector/config/config.php
vendored
24
vendor/rector/rector/config/config.php
vendored
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Bootstrap\ExtensionConfigResolver;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/services.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-rules.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-packages.php');
|
||||
$containerConfigurator->import(__DIR__ . '/parameters.php');
|
||||
$extensionConfigResolver = new \Rector\Core\Bootstrap\ExtensionConfigResolver();
|
||||
$extensionConfigFiles = $extensionConfigResolver->provide();
|
||||
foreach ($extensionConfigFiles as $extensionConfigFile) {
|
||||
$containerConfigurator->import($extensionConfigFile->getRealPath());
|
||||
}
|
||||
// require only in dev
|
||||
$containerConfigurator->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');
|
||||
// to override extension-loaded config
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH, \getcwd() . '/phpstan-for-rector.neon');
|
||||
};
|
28
vendor/rector/rector/config/parameters.php
vendored
28
vendor/rector/rector/config/parameters.php
vendored
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\ProjectType;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
// paths and extensions
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PATHS, []);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::FILE_EXTENSIONS, ['php']);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS, []);
|
||||
// these files will be executed, useful e.g. for constant definitions
|
||||
$parameters->set(\Rector\Core\Configuration\Option::BOOTSTRAP_FILES, []);
|
||||
// FQN class importing
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_DOC_BLOCKS, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, null);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PROJECT_TYPE, \Rector\Core\ValueObject\ProjectType::PROPRIETARY);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::SKIP, []);
|
||||
// cache
|
||||
$parameters->set(\Rector\Core\Configuration\Option::ENABLE_CACHE, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::CACHE_DIR, \sys_get_temp_dir() . '/rector_cached_files');
|
||||
};
|
|
@ -1,2 +0,0 @@
|
|||
parameters:
|
||||
inferPrivatePropertyTypeFromConstructor: true
|
|
@ -1,15 +0,0 @@
|
|||
parameters:
|
||||
# see https://github.com/rectorphp/rector/issues/3490#issue-634342324
|
||||
featureToggles:
|
||||
disableRuntimeReflectionProvider: false
|
||||
|
||||
services:
|
||||
- Rector\NodeTypeResolver\Reflection\BetterReflection\RectorBetterReflectionSourceLocatorFactory
|
||||
- Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator
|
||||
- Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider
|
||||
|
||||
# basically decorates native PHPStan source locator with a dynamic source locator that is also available in Rector DI
|
||||
betterReflectionSourceLocator:
|
||||
class: PHPStan\BetterReflection\SourceLocator\Type\SourceLocator
|
||||
factory: ['@Rector\NodeTypeResolver\Reflection\BetterReflection\RectorBetterReflectionSourceLocatorFactory', 'create']
|
||||
autowired: false
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\', __DIR__ . '/../packages')->exclude([
|
||||
__DIR__ . '/../packages/*/{ValueObject,Contract,Exception}',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php',
|
||||
__DIR__ . '/../packages/Testing/PHPUnit',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDoc',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php',
|
||||
// used in PHPStan
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
|
||||
]);
|
||||
};
|
18
vendor/rector/rector/config/services-rules.php
vendored
18
vendor/rector/rector/config/services-rules.php
vendored
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\PSR4\Composer\PSR4NamespaceMatcher;
|
||||
use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::TYPES_TO_REMOVE_STATIC_FROM, []);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
// psr-4
|
||||
$services->alias(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface::class, \Rector\PSR4\Composer\PSR4NamespaceMatcher::class);
|
||||
$services->load('Rector\\', __DIR__ . '/../rules')->exclude([__DIR__ . '/../rules/*/{ValueObject,Rector,Contract,Exception}']);
|
||||
};
|
108
vendor/rector/rector/config/services.php
vendored
108
vendor/rector/rector/config/services.php
vendored
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use RectorPrefix20210510\Composer\Semver\VersionParser;
|
||||
use RectorPrefix20210510\Doctrine\Inflector\Inflector;
|
||||
use RectorPrefix20210510\Doctrine\Inflector\Rules\English\InflectorFactory;
|
||||
use RectorPrefix20210510\Ergebnis\Json\Printer\Printer;
|
||||
use RectorPrefix20210510\Ergebnis\Json\Printer\PrinterInterface;
|
||||
use RectorPrefix20210510\Idiosyncratic\EditorConfig\EditorConfig;
|
||||
use RectorPrefix20210510\Nette\Caching\Cache;
|
||||
use PhpParser\BuilderFactory;
|
||||
use PhpParser\Lexer;
|
||||
use PhpParser\NodeFinder;
|
||||
use PhpParser\NodeVisitor\CloningVisitor;
|
||||
use PhpParser\NodeVisitor\NodeConnectingVisitor;
|
||||
use PhpParser\Parser;
|
||||
use PhpParser\ParserFactory;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use PHPStan\Analyser\ScopeFactory;
|
||||
use PHPStan\Dependency\DependencyResolver;
|
||||
use PHPStan\File\FileHelper;
|
||||
use PHPStan\PhpDoc\TypeNodeResolver;
|
||||
use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use RectorPrefix20210510\PrettyXml\Formatter;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser;
|
||||
use Rector\Caching\Cache\NetteCacheFactory;
|
||||
use Rector\Core\Console\ConsoleApplication;
|
||||
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
|
||||
use Rector\Core\PhpParser\Parser\PhpParserLexerFactory;
|
||||
use Rector\FileFormatter\Contract\EditorConfig\EditorConfigParserInterface;
|
||||
use Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser;
|
||||
use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
use RectorPrefix20210510\Symfony\Component\Console\Application as SymfonyApplication;
|
||||
use RectorPrefix20210510\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use function RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
use RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Strings\StringFormatConverter;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemFilter;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\Json\JsonFileSystem;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\Core\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/Exception', __DIR__ . '/../src/DependencyInjection/CompilerPass', __DIR__ . '/../src/DependencyInjection/Loader', __DIR__ . '/../src/HttpKernel', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Bootstrap', __DIR__ . '/../src/PhpParser/Node/CustomNode', __DIR__ . '/../src/functions', __DIR__ . '/../src/constants.php']);
|
||||
$services->alias(\RectorPrefix20210510\Symfony\Component\Console\Application::class, \Rector\Core\Console\ConsoleApplication::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemGuard::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class);
|
||||
$services->set(\PhpParser\ParserFactory::class);
|
||||
$services->set(\PhpParser\BuilderFactory::class);
|
||||
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
|
||||
$services->set(\PhpParser\NodeFinder::class);
|
||||
$services->set(\PhpParser\Parser::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\PhpParserLexerFactory::class), 'create']);
|
||||
// symplify/package-builder
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\Finder\FinderSanitizer::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemFilter::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Command\CommandNaming::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\SmartFileSystem::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Strings\StringFormatConverter::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class);
|
||||
$services->set(\RectorPrefix20210510\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\Json\JsonFileSystem::class);
|
||||
$services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class);
|
||||
$services->set(\RectorPrefix20210510\Doctrine\Inflector\Rules\English\InflectorFactory::class);
|
||||
$services->set(\RectorPrefix20210510\Doctrine\Inflector\Inflector::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210510\Doctrine\Inflector\Rules\English\InflectorFactory::class), 'build']);
|
||||
$services->set(\RectorPrefix20210510\Composer\Semver\VersionParser::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Php\TypeChecker::class);
|
||||
// phpdoc parser
|
||||
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\PhpDocParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser::class);
|
||||
// cache
|
||||
$services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']);
|
||||
$services->set(\PHPStan\File\FileHelper::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createFileHelper']);
|
||||
$services->set(\RectorPrefix20210510\Nette\Caching\Cache::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\Cache\NetteCacheFactory::class), 'create']);
|
||||
// type resolving
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class);
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class);
|
||||
// PHPStan services
|
||||
$services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']);
|
||||
$services->set(\PHPStan\Analyser\NodeScopeResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
||||
$services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']);
|
||||
$services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||
$services->set(\RectorPrefix20210510\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->alias(\RectorPrefix20210510\Ergebnis\Json\Printer\PrinterInterface::class, \RectorPrefix20210510\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->set(\RectorPrefix20210510\PrettyXml\Formatter::class);
|
||||
$services->set(\RectorPrefix20210510\Idiosyncratic\EditorConfig\EditorConfig::class);
|
||||
$services->alias(\Rector\FileFormatter\Contract\EditorConfig\EditorConfigParserInterface::class, \Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser::class);
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
|
||||
use Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class);
|
||||
$services->set(\Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector::class);
|
||||
};
|
14
vendor/rector/rector/config/set/carbon-2.php
vendored
14
vendor/rector/rector/config/set/carbon-2.php
vendored
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector;
|
||||
use Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# source: https://carbon.nesbot.com/docs/#api-carbon-2
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector::class);
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector::class);
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
|
||||
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector;
|
||||
use Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
};
|
177
vendor/rector/rector/config/set/code-quality.php
vendored
177
vendor/rector/rector/config/set/code-quality.php
vendored
|
@ -1,177 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector;
|
||||
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
|
||||
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
|
||||
use Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector;
|
||||
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
|
||||
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
|
||||
use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
|
||||
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
|
||||
use Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector;
|
||||
use Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector;
|
||||
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
|
||||
use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
|
||||
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
|
||||
use Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector;
|
||||
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector;
|
||||
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
|
||||
use Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector;
|
||||
use Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector;
|
||||
use Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector;
|
||||
use Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector;
|
||||
use Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector;
|
||||
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
|
||||
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
|
||||
use Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector;
|
||||
use Rector\CodeQuality\Rector\If_\CombineIfRector;
|
||||
use Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector;
|
||||
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
|
||||
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
|
||||
use Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector;
|
||||
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
|
||||
use Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector;
|
||||
use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector;
|
||||
use Rector\CodeQuality\Rector\Name\FixClassCaseSensitivityNameRector;
|
||||
use Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector;
|
||||
use Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector;
|
||||
use Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector;
|
||||
use Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\SimplifyDuplicatedTernaryRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
|
||||
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
|
||||
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\CombineIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyDuplicatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForToForeachRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'split' => 'explode',
|
||||
'join' => 'implode',
|
||||
'sizeof' => 'count',
|
||||
# https://www.php.net/manual/en/aliases.php
|
||||
'chop' => 'rtrim',
|
||||
'doubleval' => 'floatval',
|
||||
'gzputs' => 'gzwrites',
|
||||
'fputs' => 'fwrite',
|
||||
'ini_alter' => 'ini_set',
|
||||
'is_double' => 'is_float',
|
||||
'is_integer' => 'is_int',
|
||||
'is_long' => 'is_int',
|
||||
'is_real' => 'is_float',
|
||||
'is_writeable' => 'is_writable',
|
||||
'key_exists' => 'array_key_exists',
|
||||
'pos' => 'current',
|
||||
'strchr' => 'strstr',
|
||||
# mb
|
||||
'mbstrcut' => 'mb_strcut',
|
||||
'mbstrlen' => 'mb_strlen',
|
||||
'mbstrpos' => 'mb_strpos',
|
||||
'mbstrrpos' => 'mb_strrpos',
|
||||
'mbsubstr' => 'mb_substr',
|
||||
]]]);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Name\FixClassCaseSensitivityNameRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector::class);
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
};
|
71
vendor/rector/rector/config/set/coding-style.php
vendored
71
vendor/rector/rector/config/set/coding-style.php
vendored
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector;
|
||||
use Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector;
|
||||
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
|
||||
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
|
||||
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
|
||||
use Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector;
|
||||
use Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
|
||||
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
|
||||
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
|
||||
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
|
||||
use Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector;
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector;
|
||||
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
|
||||
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
|
||||
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
|
||||
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
|
||||
use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector;
|
||||
use Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector;
|
||||
use Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector;
|
||||
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']]]);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
|
||||
};
|
98
vendor/rector/rector/config/set/dead-code.php
vendored
98
vendor/rector/rector/config/set/dead-code.php
vendored
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector;
|
||||
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
|
||||
use Rector\DeadCode\Rector\Assign\RemoveAssignOfVoidReturnFunctionRector;
|
||||
use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
|
||||
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
|
||||
use Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector;
|
||||
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
|
||||
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
|
||||
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
|
||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
|
||||
use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector;
|
||||
use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
|
||||
use Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector;
|
||||
use Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector;
|
||||
use Rector\DeadCode\Rector\For_\RemoveDeadLoopRector;
|
||||
use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector;
|
||||
use Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector;
|
||||
use Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector;
|
||||
use Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector;
|
||||
use Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector;
|
||||
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
|
||||
use Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector;
|
||||
use Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector;
|
||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
|
||||
use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
|
||||
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
|
||||
use Rector\DeadCode\Rector\Property\RemoveSetterOnlyPropertyAndMethodCallRector;
|
||||
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
|
||||
use Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector;
|
||||
use Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector;
|
||||
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
|
||||
use Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector;
|
||||
use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
|
||||
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
|
||||
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
|
||||
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveSetterOnlyPropertyAndMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class);
|
||||
$services->set(\Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveAssignOfVoidReturnFunctionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class);
|
||||
// docblock
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class);
|
||||
};
|
29
vendor/rector/rector/config/set/defluent.php
vendored
29
vendor/rector/rector/config/set/defluent.php
vendored
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Defluent\Rector\ClassMethod\ReturnThisRemoveRector;
|
||||
use Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector;
|
||||
use Rector\Defluent\Rector\MethodCall\InArgFluentChainMethodCallToStandaloneMethodCallRector;
|
||||
use Rector\Defluent\Rector\MethodCall\MethodCallOnSetterMethodCallToStandaloneAssignRector;
|
||||
use Rector\Defluent\Rector\MethodCall\NewFluentChainMethodCallToNonFluentRector;
|
||||
use Rector\Defluent\Rector\Return_\DefluentReturnMethodCallRector;
|
||||
use Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector;
|
||||
use Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
|
||||
// @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
// variable/property
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector::class);
|
||||
// new
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\NewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\ClassMethod\ReturnThisRemoveRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\DefluentReturnMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\MethodCallOnSetterMethodCallToStandaloneAssignRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\InArgFluentChainMethodCallToStandaloneMethodCallRector::class);
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_53);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector;
|
||||
use Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector;
|
||||
use Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector;
|
||||
use Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector;
|
||||
use Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector;
|
||||
use Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector;
|
||||
use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
|
||||
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
|
||||
use Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_56);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector::class);
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector;
|
||||
use Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector;
|
||||
use Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector;
|
||||
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector;
|
||||
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector;
|
||||
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector;
|
||||
use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector;
|
||||
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
|
||||
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_70);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class);
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector;
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_71);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
|
||||
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
||||
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_72);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
|
||||
};
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector;
|
||||
use Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector;
|
||||
use Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector;
|
||||
use Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector;
|
||||
use Rector\DowngradePhp74\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector;
|
||||
use Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector;
|
||||
use Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector;
|
||||
use Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector;
|
||||
use Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector;
|
||||
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
|
||||
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_73);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class);
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
|
||||
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
|
||||
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
|
||||
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class);
|
||||
};
|
31
vendor/rector/rector/config/set/early-return.php
vendored
31
vendor/rector/rector/config/set/early-return.php
vendored
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
|
||||
use Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class);
|
||||
};
|
29
vendor/rector/rector/config/set/flysystem-20.php
vendored
29
vendor/rector/rector/config/set/flysystem-20.php
vendored
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// Rename is now move, specific for files.
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'rename', 'move'),
|
||||
// No arbitrary abbreviations
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'createDir', 'createDirectory'),
|
||||
// Writes are now deterministic
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'update', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'updateStream', 'writeStream'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'put', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'putStream', 'writeStream'),
|
||||
// Metadata getters are renamed
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getTimestamp', 'lastModified'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'has', 'fileExists'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getMimetype', 'mimeType'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getSize', 'fileSize'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getVisibility', 'visibility'),
|
||||
])]]);
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
|
||||
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class);
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class);
|
||||
};
|
File diff suppressed because one or more lines are too long
23
vendor/rector/rector/config/set/guzzle50.php
vendored
23
vendor/rector/rector/config/set/guzzle50.php
vendored
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
|
||||
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# both uses "%classes_to_defluent%
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline($configuration)]]);
|
||||
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')])]]);
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Core\ValueObject\Visibility;
|
||||
use Rector\NetteToSymfony\Rector\MethodCall\WrapTransParameterNameRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
|
||||
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class)->call('configure', [[\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::METHOD_VISIBILITIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', \Rector\Core\ValueObject\Visibility::STATIC)])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans'), new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface', 'Kdyby\\Monolog\\Logger' => 'Psr\\Log\\LoggerInterface', 'Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Translation\\Translator' => 'Symfony\\Contracts\\Translation\\TranslatorInterface']]]);
|
||||
$services->set(\Rector\NetteToSymfony\Rector\MethodCall\WrapTransParameterNameRector::class);
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use PHPStan\Type\ObjectWithoutClassType;
|
||||
use PHPStan\Type\StringType;
|
||||
use PHPStan\Type\VoidType;
|
||||
use Rector\Composer\Rector\ChangePackageVersionComposerRector;
|
||||
use Rector\Composer\ValueObject\PackageAndVersion;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\LeagueEvent\Rector\MethodCall\DispatchStringToObjectRector;
|
||||
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
|
||||
use Rector\Removing\Rector\Class_\RemoveParentRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Transform\Rector\Class_\AddInterfaceByParentRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Composer\Rector\ChangePackageVersionComposerRector::class)->call('configure', [[\Rector\Composer\Rector\ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Composer\ValueObject\PackageAndVersion('league/event', '^3.0')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EventInterface', 'getName', 'eventName'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'emit', 'dispatch'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addListener', 'subscribeTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addOneTimeListener', 'subscribeOneTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'useListenerProvider', 'subscribeListenersFrom'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\ListenerInterface', 'handle', '__invoke')])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', 0, new \PHPStan\Type\ObjectWithoutClassType())])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\EventInterface', 'eventName', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', new \PHPStan\Type\VoidType())])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['League\\Event\\Emitter' => 'League\\Event\\EventDispatcher', 'League\\Event\\ListenerInterface' => 'League\\Event\\Listener', 'League\\Event\\GeneratorInterface' => 'League\\Event\\EventGenerator', 'League\\Event\\ListenerProviderInterface' => 'League\\Event\\ListenerSubscriber', 'League\\Event\\ListenerAcceptorInterface' => 'League\\Event\\ListenerRegistry']]]);
|
||||
$services->set(\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::class)->call('configure', [[\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::INTERFACE_BY_PARENT => ['League\\Event\\Event' => 'League\\Event\\HasEventName', 'League\\Event\\AbstractListener' => 'League\\Event\\Listener']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['League\\Event\\EventInterface']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveParentRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveParentRector::PARENT_TYPES_TO_REMOVE => ['League\\Event\\AbstractEvent', 'League\\Event\\Event', 'League\\Event\\AbstractListener']]]);
|
||||
$services->set(\Rector\LeagueEvent\Rector\MethodCall\DispatchStringToObjectRector::class);
|
||||
};
|
14
vendor/rector/rector/config/set/monolog20.php
vendored
14
vendor/rector/rector/config/set/monolog20.php
vendored
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')])]]);
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector;
|
||||
use Rector\Arguments\ValueObject\SwapFuncCallArguments;
|
||||
use Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector;
|
||||
use Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector;
|
||||
use Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector;
|
||||
use Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector;
|
||||
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# https://stackoverflow.com/a/1390625/1348344
|
||||
# https://github.com/philip/MySQLConverterTool/blob/master/Converter.php
|
||||
# https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)])]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
|
||||
# first swap arguments, then rename
|
||||
$services->set(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])])]]);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']]]);
|
||||
# http://php.net/manual/en/mysql.constants.php → http://php.net/manual/en/mysqli.constants.php
|
||||
$services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
|
||||
};
|
27
vendor/rector/rector/config/set/naming.php
vendored
27
vendor/rector/rector/config/set/naming.php
vendored
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
|
||||
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
|
||||
use Rector\Naming\Rector\ClassMethod\MakeGetterClassMethodNameStartWithGetRector;
|
||||
use Rector\Naming\Rector\ClassMethod\MakeIsserClassMethodNameStartWithIsRector;
|
||||
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
|
||||
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
|
||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
|
||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
|
||||
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeGetterClassMethodNameStartWithGetRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeIsserClassMethodNameStartWithIsRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||
};
|
19
vendor/rector/rector/config/set/order.php
vendored
19
vendor/rector/rector/config/set/order.php
vendored
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Order\Rector\Class_\OrderClassConstantsByIntegerValueRector;
|
||||
use Rector\Order\Rector\Class_\OrderConstantsByVisibilityRector;
|
||||
use Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector;
|
||||
use Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector;
|
||||
use Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderClassConstantsByIntegerValueRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderConstantsByVisibilityRector::class);
|
||||
};
|
19
vendor/rector/rector/config/set/phalcon40.php
vendored
19
vendor/rector/rector/config/set/phalcon40.php
vendored
File diff suppressed because one or more lines are too long
20
vendor/rector/rector/config/set/php52.php
vendored
20
vendor/rector/rector/config/set/php52.php
vendored
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
||||
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
|
||||
new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2),
|
||||
])]]);
|
||||
};
|
17
vendor/rector/rector/config/set/php53.php
vendored
17
vendor/rector/rector/config/set/php53.php
vendored
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector;
|
||||
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
||||
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
||||
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
|
||||
$services->set(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
|
||||
$services->set(\Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector::class);
|
||||
$services->set(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
|
||||
};
|
15
vendor/rector/rector/config/set/php54.php
vendored
15
vendor/rector/rector/config/set/php54.php
vendored
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
||||
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysqli_param_count' => 'mysqli_stmt_param_count']]]);
|
||||
$services->set(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
|
||||
$services->set(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
|
||||
};
|
13
vendor/rector/rector/config/set/php55.php
vendored
13
vendor/rector/rector/config/set/php55.php
vendored
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class);
|
||||
};
|
16
vendor/rector/rector/config/set/php56.php
vendored
16
vendor/rector/rector/config/set/php56.php
vendored
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
||||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']]]);
|
||||
# inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
|
||||
$services->set(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class);
|
||||
};
|
49
vendor/rector/rector/config/set/php70.php
vendored
49
vendor/rector/rector/config/set/php70.php
vendored
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php70\Rector\Assign\ListSplitStringRector;
|
||||
use Rector\Php70\Rector\Assign\ListSwapArrayOrderRector;
|
||||
use Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector;
|
||||
use Rector\Php70\Rector\ClassMethod\Php4ConstructorRector;
|
||||
use Rector\Php70\Rector\FuncCall\CallUserMethodRector;
|
||||
use Rector\Php70\Rector\FuncCall\EregToPregMatchRector;
|
||||
use Rector\Php70\Rector\FuncCall\MultiDirnameRector;
|
||||
use Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector;
|
||||
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
|
||||
use Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector;
|
||||
use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector;
|
||||
use Rector\Php70\Rector\If_\IfToSpaceshipRector;
|
||||
use Rector\Php70\Rector\List_\EmptyListRector;
|
||||
use Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector;
|
||||
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
|
||||
use Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector;
|
||||
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
||||
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
|
||||
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/mysql-to-mysqli.php');
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSplitStringRector::class);
|
||||
$services->set(\Rector\Php70\Rector\List_\EmptyListRector::class);
|
||||
# be careful, run this just once, since it can keep swapping order back and forth
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSwapArrayOrderRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class);
|
||||
$services->set(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class);
|
||||
};
|
23
vendor/rector/rector/config/set/php71.php
vendored
23
vendor/rector/rector/config/set/php71.php
vendored
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php71\Rector\Assign\AssignArrayToStringRector;
|
||||
use Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector;
|
||||
use Rector\Php71\Rector\BooleanOr\IsIterableRector;
|
||||
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
|
||||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
||||
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class);
|
||||
$services->set(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class);
|
||||
$services->set(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class);
|
||||
};
|
41
vendor/rector/rector/config/set/php72.php
vendored
41
vendor/rector/rector/config/set/php72.php
vendored
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php72\Rector\Assign\ListEachRector;
|
||||
use Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector;
|
||||
use Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector;
|
||||
use Rector\Php72\Rector\FuncCall\GetClassOnNullRector;
|
||||
use Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector;
|
||||
use Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector;
|
||||
use Rector\Php72\Rector\FuncCall\StringifyDefineRector;
|
||||
use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector;
|
||||
use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
||||
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ListEachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# and imagewbmp
|
||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||
# or imagewbmp
|
||||
'png2wbmp' => 'imagecreatefrompng',
|
||||
#migration72.deprecated.gmp_random-function
|
||||
# http://php.net/manual/en/migration72.deprecated.php
|
||||
# or gmp_random_range
|
||||
'gmp_random' => 'gmp_random_bits',
|
||||
'read_exif_data' => 'exif_read_data',
|
||||
]]]);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
|
||||
};
|
45
vendor/rector/rector/config/set/php73.php
vendored
45
vendor/rector/rector/config/set/php73.php
vendored
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
||||
use Rector\Php73\Rector\BooleanOr\IsCountableRector;
|
||||
use Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector;
|
||||
use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector;
|
||||
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
|
||||
use Rector\Php73\Rector\FuncCall\RegexDashEscapeRector;
|
||||
use Rector\Php73\Rector\FuncCall\SensitiveDefineRector;
|
||||
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
||||
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
|
||||
$services->set(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
|
||||
$services->set(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_3
|
||||
'image2wbmp' => 'imagewbmp',
|
||||
'mbregex_encoding' => 'mb_regex_encoding',
|
||||
'mbereg' => 'mb_ereg',
|
||||
'mberegi' => 'mb_eregi',
|
||||
'mbereg_replace' => 'mb_ereg_replace',
|
||||
'mberegi_replace' => 'mb_eregi_replace',
|
||||
'mbsplit' => 'mb_split',
|
||||
'mbereg_match' => 'mb_ereg_match',
|
||||
'mbereg_search' => 'mb_ereg_search',
|
||||
'mbereg_search_pos' => 'mb_ereg_search_pos',
|
||||
'mbereg_search_regs' => 'mb_ereg_search_regs',
|
||||
'mbereg_search_init' => 'mb_ereg_search_init',
|
||||
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
|
||||
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
||||
]]]);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
};
|
46
vendor/rector/rector/config/set/php74.php
vendored
46
vendor/rector/rector/config/set/php74.php
vendored
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
|
||||
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
|
||||
use Rector\Php74\Rector\Double\RealToFloatTypeCastRector;
|
||||
use Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector;
|
||||
use Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
|
||||
use Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector;
|
||||
use Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector;
|
||||
use Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector;
|
||||
use Rector\Php74\Rector\Function_\ReservedFnFunctionRector;
|
||||
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
|
||||
use Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector;
|
||||
use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
#the_real_type
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'is_real' => 'is_float',
|
||||
#apache_request_headers_function
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'apache_request_headers' => 'getallheaders',
|
||||
]]]);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
|
||||
$services->set(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Function_\ReservedFnFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class);
|
||||
$services->set(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class);
|
||||
$services->set(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||
};
|
49
vendor/rector/rector/config/set/php80.php
vendored
49
vendor/rector/rector/config/set/php80.php
vendored
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
|
||||
use Rector\Arguments\ValueObject\ArgumentAdder;
|
||||
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
|
||||
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
|
||||
use Rector\Php80\Rector\Class_\StringableForToStringRector;
|
||||
use Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector;
|
||||
use Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
|
||||
use Rector\Php80\Rector\ClassMethod\SetStateToStaticRector;
|
||||
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
|
||||
use Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector;
|
||||
use Rector\Php80\Rector\FunctionLike\UnionTypesRector;
|
||||
use Rector\Php80\Rector\Identical\StrEndsWithRector;
|
||||
use Rector\Php80\Rector\Identical\StrStartsWithRector;
|
||||
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
|
||||
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
|
||||
use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
|
||||
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
|
||||
// nette\utils and Strings::replace()
|
||||
$services->set(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')])]]);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
|
||||
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']]]);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
|
||||
};
|
11
vendor/rector/rector/config/set/php81.php
vendored
11
vendor/rector/rector/config/set/php81.php
vendored
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
|
||||
};
|
File diff suppressed because one or more lines are too long
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\RenameSpecFileToTestFileRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# see: https://gnugat.github.io/2015/09/23/phpunit-with-phpspec.html
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# 1. first convert mocks
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
# 2. then methods
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
# 3. then the class itself
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\RenameSpecFileToTestFileRector::class);
|
||||
};
|
19
vendor/rector/rector/config/set/phpspec30.php
vendored
19
vendor/rector/rector/config/set/phpspec30.php
vendored
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// @see http://www.phpspec.net/en/stable/manual/upgrading-to-phpspec-3.html
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'set', 'define'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'setShared', 'define'),
|
||||
])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']]]);
|
||||
};
|
16
vendor/rector/rector/config/set/phpspec40.php
vendored
16
vendor/rector/rector/config/set/phpspec40.php
vendored
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType());
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)])]]);
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Privatization\Rector\Class_\ChangeLocalPropertyToVariableRector;
|
||||
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
|
||||
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
|
||||
use Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector;
|
||||
use Rector\Privatization\Rector\ClassMethod\ChangeGlobalVariablesToPropertiesRector;
|
||||
use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
|
||||
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
|
||||
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
|
||||
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
||||
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\ChangeGlobalVariablesToPropertiesRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class);
|
||||
// buggy, requires more work
|
||||
// $services->set(ChangeLocalPropertyToVariableRector::class);
|
||||
};
|
13
vendor/rector/rector/config/set/psr-4.php
vendored
13
vendor/rector/rector/config/set/psr-4.php
vendored
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
||||
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||
$services->set(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class);
|
||||
};
|
12
vendor/rector/rector/config/set/safe07.php
vendored
12
vendor/rector/rector/config/set/safe07.php
vendored
File diff suppressed because one or more lines are too long
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
|
||||
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class);
|
||||
// $services->set(AddMethodCallBasedStrictParamTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class);
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromCallersRector;
|
||||
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class);
|
||||
// $services->set(AddParamTypeFromCallersRector::class);
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
};
|
70
vendor/rector/rector/docs/auto_import_names.md
vendored
70
vendor/rector/rector/docs/auto_import_names.md
vendored
|
@ -1,70 +0,0 @@
|
|||
# Auto Import Names
|
||||
|
||||
Rector works with all class names as fully qualified by default, so it know the exact types. In most coding standard, that's not desired behavior, because short version with `use` statement is preferred:
|
||||
|
||||
```diff
|
||||
-$object = new \App\Some\Namespace\SomeClass();
|
||||
+use App\Some\Namespace\SomeClass;
|
||||
+$object = new SomeClass();
|
||||
```
|
||||
|
||||
|
||||
To import FQN like these, configure `rector.php` with:
|
||||
|
||||
```php
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
If you enable this feature, the class names in docblocks are imported as well:
|
||||
|
||||
```diff
|
||||
+use App\Some\Namespace\SomeClass;
|
||||
-/** @var \App\Some\Namespace\SomeClass $someClass */
|
||||
+/** @var SomeClass $someClass */
|
||||
$someClass = ...;
|
||||
```
|
||||
|
||||
Do you want to skip them?
|
||||
|
||||
```php
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
Single short classes are imported too:
|
||||
|
||||
```diff
|
||||
+use DateTime;
|
||||
-$someClass = \DateTime();
|
||||
+$someClass = DateTime();
|
||||
```
|
||||
|
||||
Do you want to keep those?
|
||||
|
||||
```php
|
||||
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);
|
||||
```
|
||||
|
||||
## How to Remove Unused Imports?
|
||||
|
||||
To remove imports, use [ECS](github.com/symplify/easy-coding-standard) with [`NoUnusedImportsFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.18/doc/rules/import/no_unused_imports.rst) rule:
|
||||
|
||||
```php
|
||||
// ecs.php
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(NoUnusedImportsFixer::class);
|
||||
};
|
||||
```
|
||||
|
||||
Run it:
|
||||
|
||||
```bash
|
||||
vendor/bin/ecs check src --fix
|
||||
```
|
148
vendor/rector/rector/docs/create_own_rule.md
vendored
148
vendor/rector/rector/docs/create_own_rule.md
vendored
|
@ -1,148 +0,0 @@
|
|||
# 3 Steps to Create Your Own Rector
|
||||
|
||||
First, make sure it's not covered by [any existing Rectors](/docs/rector_rules_overview.md).
|
||||
Let's say we want to **change method calls from `set*` to `change*`**.
|
||||
|
||||
```diff
|
||||
$user = new User();
|
||||
-$user->setPassword('123456');
|
||||
+$user->changePassword('123456');
|
||||
```
|
||||
|
||||
## 1. Create a New Rector and Implement Methods
|
||||
|
||||
Create a class that extends [`Rector\Core\Rector\AbstractRector`](/src/Rector/AbstractRector.php). It will inherit useful methods e.g. to check node type and name. See the source (or type `$this->` in an IDE) for a list of available methods.
|
||||
|
||||
```php
|
||||
namespace Utils\Rector;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
final class MyFirstRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
// what node types are we looking for?
|
||||
// pick any node from https://github.com/rectorphp/php-parser-nodes-docs/
|
||||
return [MethodCall::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $node - we can add "MethodCall" type here, because
|
||||
* only this node is in "getNodeTypes()"
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
// we only care about "set*" method names
|
||||
if (! $this->isName($node->name, 'set*')) {
|
||||
// return null to skip it
|
||||
return null;
|
||||
}
|
||||
|
||||
$methodCallName = $this->getName($node->name);
|
||||
$newMethodCallName = Strings::replace($methodCallName, '#^set#', 'change');
|
||||
|
||||
$node->name = new Identifier($newMethodCallName);
|
||||
|
||||
// return $node if you modified it
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* From this method documentation is generated.
|
||||
*/
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
{
|
||||
return new RuleDefinition(
|
||||
'Change method calls from set* to change*.', [
|
||||
new CodeSample(
|
||||
// code before
|
||||
'$user->setPassword("123456");',
|
||||
// code after
|
||||
'$user->changePassword("123456");'
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This is how the file structure should look like:
|
||||
|
||||
```bash
|
||||
/src/YourCode.php
|
||||
/utils/Rector/MyFirstRector.php
|
||||
rector.php
|
||||
composer.json
|
||||
```
|
||||
|
||||
We also need to load Rector rules in `composer.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Utils\\": "utils"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
After adding this to `composer.json`, be sure to reload Composer's class map:
|
||||
|
||||
```bash
|
||||
composer dump-autoload
|
||||
```
|
||||
|
||||
## 2. Register It
|
||||
|
||||
```php
|
||||
<?php
|
||||
// rector.php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Utils\Rector\MyFirstRector;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MyFirstRector::class);
|
||||
};
|
||||
```
|
||||
|
||||
## 3. Let Rector Refactor Your Code
|
||||
|
||||
The `rector.php` configuration is loaded by default, so we can skip it.
|
||||
|
||||
```bash
|
||||
# see the diff first
|
||||
vendor/bin/rector process src --dry-run
|
||||
|
||||
# if it's ok, apply
|
||||
vendor/bin/rector process src
|
||||
```
|
||||
|
||||
That's it!
|
||||
|
||||
<br>
|
||||
|
||||
## Generating a Rector Rule
|
||||
|
||||
Do you want to save time with making rules and tests?
|
||||
|
||||
Use [the `generate` command](https://github.com/rectorphp/rector-generator).
|
102
vendor/rector/rector/docs/how_it_works.md
vendored
102
vendor/rector/rector/docs/how_it_works.md
vendored
|
@ -1,102 +0,0 @@
|
|||
# How Does Rector Work?
|
||||
|
||||
(Inspired by [*How it works* in BetterReflection](https://github.com/Roave/BetterReflection/blob/master/docs/how-it-works.md))
|
||||
|
||||
## 1. Finds all files and Load Configured Rectors
|
||||
|
||||
- The application finds files in the source code you provide and registered Rectors - from `--config` or local `rector.php`
|
||||
- Then it iterates all found files and applies relevant Rectors to them.
|
||||
- A *Rector* in this context is 1 single class that modifies 1 thing, e.g. changes the class name
|
||||
|
||||
## 2. Parse and Reconstruct 1 File
|
||||
|
||||
The iteration of files, nodes and Rectors respects this lifecycle:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Contract\Rector\PhpRectorInterface;
|
||||
use PhpParser\Parser;
|
||||
|
||||
/** @var SplFileInfo[] $fileInfos */
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
// 1 file => nodes
|
||||
/** @var Parser $phpParser */
|
||||
$nodes = $phpParser->parse(file_get_contents($fileInfo->getRealPath()));
|
||||
|
||||
// nodes => 1 node
|
||||
foreach ($nodes as $node) { // rather traverse all of them
|
||||
/** @var PhpRectorInterface[] $rectors */
|
||||
foreach ($rectors as $rector) {
|
||||
foreach ($rector->getNodeTypes() as $nodeType) {
|
||||
if (is_a($node, $nodeType, true)) {
|
||||
$rector->refactor($node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2.1 Prepare Phase
|
||||
|
||||
- Files are parsed by [`nikic/php-parser`](https://github.com/nikic/PHP-Parser), 4.0 that supports writing modified tree back to a file
|
||||
- Then nodes (array of objects by parser) are traversed by `StandaloneTraverseNodeTraverser` to prepare their metadata, e.g. the class name, the method node the node is in, the namespace name etc. added by `$node->setAttribute(Attribute::CLASS_NODE, 'value')`.
|
||||
|
||||
### 2.2 Rectify Phase
|
||||
|
||||
- When all nodes are ready, the application iterates on all active Rectors
|
||||
- Each node is compared with `$rector->getNodeTypes()` method to see if this Rector should do some work on it, e.g. is this class name called `OldClassName`?
|
||||
- If it doesn't match, it goes to next node.
|
||||
- If it matches, the `$rector->reconstruct($node)` method is called
|
||||
- Active Rector change everything they have to and return changed nodes
|
||||
|
||||
### 2.2.1 Order of Rectors
|
||||
|
||||
- Rectors are run by they natural order in the configuration, meaning the first
|
||||
in the configuration will be run first.
|
||||
|
||||
E.g. in this case, first the `@expectedException` annotation will be changed to a method,
|
||||
then the `setExpectedException` method will be changed to `expectedException`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// rector.php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector::class);
|
||||
$services->set(Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)
|
||||
->arg('$oldToNewMethodsByClass', [
|
||||
PHPUnit\Framework\TestClass::class => [
|
||||
'setExpectedException' => 'expectedException',
|
||||
'setExpectedExceptionRegExp' => 'expectedException',
|
||||
],
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
### 2.3 Save File/Diff Phase
|
||||
|
||||
- When work on all nodes of 1 file is done, the file will be saved if it has some changes
|
||||
- Or if the `--dry-run` option is on, it will store the *git-like* diff thanks to [GeckoPackages/GeckoDiffOutputBuilder](https://github.com/GeckoPackages/GeckoDiffOutputBuilder)
|
||||
- Then Rector will go to the next file
|
||||
|
||||
## 3 Reporting
|
||||
|
||||
- After this, Rector displays the list of changed files
|
||||
- Or with `--dry-run` option the diff of these files
|
||||
|
||||
### Similar Projects
|
||||
|
||||
- [ClangMR](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/41342.pdf) for C++ by Google (closed source) - almost idential workflow, developed independently though
|
||||
- [hhast](https://github.com/hhvm/hhast) - HHVM AST + format preserving + mirations
|
||||
- [facebook/jscodeshift](https://github.com/facebook/jscodeshift) for Javascript
|
||||
- [silverstripe/silverstripe-upgrader](https://github.com/silverstripe/silverstripe-upgrader) for PHP CMS, Silverstripe
|
||||
- [dereuromark/upgrade](https://github.com/dereuromark/upgrade) for PHP Framework, CakePHP
|
|
@ -1,125 +0,0 @@
|
|||
# How to Add Test for Rector Rule
|
||||
|
||||
## 1. Detect the Rector Rule
|
||||
|
||||
Run Rector only on 1 directory, or better 1 file.
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process /some-file.php
|
||||
```
|
||||
|
||||
See "Applied rules" under the diff:
|
||||
|
||||
![Applied Rules](/docs/images/docs_applied_rules.png)
|
||||
|
||||
Our rule in this example is: `Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector`
|
||||
|
||||
This rule's job is to add `final` to every class that has no children and is not a Doctrine entity = everywhere it can without breaking our code.
|
||||
|
||||
## 2. Detect the Minimal File
|
||||
|
||||
Usually, the Rector diff output is long and contains many other errors related to other rules. It's a mess; we can't use that for a test fixture. We need to find **1 responsible line**.
|
||||
|
||||
The best way is to copy the file to local code, e.g. `app/SomeFile.php` a put only the broken line there.
|
||||
|
||||
In our case, all we need is:
|
||||
|
||||
```php
|
||||
class StaticEasyPrefixer
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
Then rerun Rector to confirm:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process app/SomeFile.php
|
||||
```
|
||||
|
||||
Do we have the same diff? Great!
|
||||
|
||||
## 3. Find the Rector Test Case
|
||||
|
||||
Now we need to find the test case. The test case name is rule + `Test` suffix.
|
||||
|
||||
`FinalizeClassesWithoutChildrenRector`
|
||||
|
||||
↓
|
||||
|
||||
`FinalizeClassesWithoutChildrenRectorTest` (test class)
|
||||
|
||||
↓
|
||||
|
||||
`FinalizeClassesWithoutChildrenRectorTest.php` (test file)
|
||||
|
||||
Right here:
|
||||
|
||||
![Rule Test Case](/docs/images/docs_rule_test_case.png)
|
||||
|
||||
## 4. Add Change or No-Change Test Fixture File
|
||||
|
||||
Next to the test case, there is `/Fixture` directory. It contains many test fixture files that verified the Rector rule work correctly in all possible cases.
|
||||
|
||||
Do you see *test fixture file* first time? It's a file with real-life PHP code that test 1 specific case that rule should cover or avoid. E.g., one test fixture file can contain a Doctrine entity that cannot be final and should be skipped by this rule. By convention, the first fixture file has the name `fixture.php.inc`.
|
||||
|
||||
In the `/Fixture` directory, we create our test fixture file, e.g., `add_final.php.inc`. The `.php.inc` is there on purpose, so the file is hidden from coding standard tools and static analysis.
|
||||
|
||||
There are 2 fixture formats.
|
||||
|
||||
### 1. The Code Should Change
|
||||
|
||||
```bash
|
||||
<code before>
|
||||
-----
|
||||
<code after>
|
||||
```
|
||||
|
||||
### 2. The Code Should Be Skipped
|
||||
|
||||
```bash
|
||||
<code before>
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
In this particular case, the code should change - `final` should be added so that the test fixture would look like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector\Fixture;
|
||||
|
||||
class AddFinal
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector\Fixture;
|
||||
|
||||
final class AddFinal
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
```
|
||||
|
||||
- The closing `?>` is there for slightly better PHPStorm.
|
||||
- The PSR-4 namespace is there to make each class unique because the test classes are loaded to an analysis by reflection and must be unique
|
||||
- The file name conventions => class is `add_final.php.inc` => `AddFinal` class
|
||||
|
||||
Run PHPUnit with the test file to confirm:
|
||||
|
||||
```bash
|
||||
vendor/bin/phpunit rules-tests/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector/FinalizeClassesWithoutChildrenRectorTest.php
|
||||
```
|
||||
|
||||
To run only the single test fixture, add `--filter test#X`, where X is the fixture's order number.
|
||||
|
||||
```bash
|
||||
vendor/bin/phpunit rules-tests/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector/FinalizeClassesWithoutChildrenRectorTest.php --filter test#4
|
||||
```
|
||||
|
||||
If PHPUnit fails, you've successfully added a test case! :)
|
|
@ -1,27 +0,0 @@
|
|||
# How To Configure Rules
|
||||
|
||||
Rector rules that implement `Rector\Core\Contract\Rector\ConfigurableRectorInterface` can be configured.
|
||||
|
||||
Typical example is `Rector\Renaming\Rector\Name\RenameClassRector`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// rector.php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameClassRector::class)
|
||||
->call('configure', [[
|
||||
// we use constant for keys to save you from typos
|
||||
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
||||
'App\SomeOldClass' => 'App\SomeNewClass',
|
||||
],
|
||||
]]);
|
||||
};
|
||||
```
|
|
@ -1,69 +0,0 @@
|
|||
# How To Ignore Rule or Paths
|
||||
|
||||
## Preferred Way: Config
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// rector.php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// is there a file you need to skip?
|
||||
$parameters->set(Option::SKIP, [
|
||||
// single file
|
||||
__DIR__ . '/src/ComplicatedFile.php',
|
||||
// or directory
|
||||
__DIR__ . '/src',
|
||||
// or fnmatch
|
||||
__DIR__ . '/src/*/Tests/*',
|
||||
|
||||
// is there single rule you don't like from a set you use?
|
||||
SimplifyIfReturnBoolRector::class,
|
||||
|
||||
// or just skip rule in specific directory
|
||||
SimplifyIfReturnBoolRector::class => [
|
||||
// single file
|
||||
__DIR__ . '/src/ComplicatedFile.php',
|
||||
// or directory
|
||||
__DIR__ . '/src',
|
||||
// or fnmatch
|
||||
__DIR__ . '/src/*/Tests/*',
|
||||
],
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
## In a File
|
||||
|
||||
For in-file exclusion, use `@noRector \Rector\SomeClass\NameRector` annotation:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @noRector
|
||||
*/
|
||||
public const NAME = '102';
|
||||
|
||||
/**
|
||||
* @noRector
|
||||
*/
|
||||
public function foo(): void
|
||||
{
|
||||
/** @noRector \Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector */
|
||||
round(1 + 0);
|
||||
}
|
||||
}
|
||||
```
|
|
@ -1,37 +0,0 @@
|
|||
# How To Register Custom SetList Constant
|
||||
|
||||
You can have custom `SetList` class that has constants that pointed to your own config, for example:
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Set\ValueObject;
|
||||
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
|
||||
class SetList implements SetListInterface
|
||||
{
|
||||
public const MY_FRAMEWORK_20 = __DIR__ . '/../../../config/set/my-framework-20.php';
|
||||
}
|
||||
```
|
||||
|
||||
Now, you can register your custom `SetList`'s constant via import from `$containerConfigurator`, for example:
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
// rector.php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use App\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->import(SetList::MY_FRAMEWORK_20);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PATHS, [__DIR__ . '/src']);
|
||||
};
|
||||
```
|
|
@ -1,43 +0,0 @@
|
|||
# How to Run Rector in Docker
|
||||
|
||||
You can run Rector on your project using Docker.
|
||||
To make sure you are running latest version, use `docker pull rector/rector`.
|
||||
|
||||
*Note that Rector inside Docker expects your application in `/project` directory - it is mounted via volume from the current directory (`$pwd`).*
|
||||
|
||||
```bash
|
||||
docker run --rm -v $(pwd):/project rector/rector:latest process src --dry-run
|
||||
```
|
||||
|
||||
Using `rector.php` config:
|
||||
|
||||
```bash
|
||||
docker run --rm -v $(pwd):/project rector/rector:latest process src \
|
||||
--config rector.php \
|
||||
--dry-run
|
||||
```
|
||||
|
||||
## Multiple PHP versions supported
|
||||
|
||||
You should always use image with PHP version closest to your project's.
|
||||
|
||||
Rector Docker images supports PHP versions 7.3, 7.4, 8.0.
|
||||
|
||||
```
|
||||
## Using with specific tagged version of Rector
|
||||
rector/rector:0.9.32-php7.3
|
||||
rector/rector:0.9.32-php7.4
|
||||
rector/rector:0.9.32-php8.0
|
||||
|
||||
## Using latest release
|
||||
rector/rector:php7.3 # same as rector/rector:latest-php7.3
|
||||
rector/rector:php7.4 # same as rector/rector:latest-php7.4
|
||||
rector/rector:php8.0 # same as rector/rector:latest-php8.0
|
||||
```
|
||||
|
||||
## Permissions issues
|
||||
|
||||
If you run into issues with `permission denied` or running Rector in docker keeps changing owner of your project files, running container as current user `--user $(id -u):$(id -g)` should solve it for you:
|
||||
```
|
||||
docker run --rm --user $(id -u):$(id -g) -v $(pwd):/project rector/rector process src --config rector.php --dry-run
|
||||
```
|
|
@ -1,100 +0,0 @@
|
|||
# How To Work with Doc Block and Comments
|
||||
|
||||
Let's say we have a doc block:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
```
|
||||
|
||||
## How to get a Return Type?
|
||||
|
||||
To get e.g. return type, use `PhpDocInfo` value object with useful methods:
|
||||
|
||||
```php
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
|
||||
/** @var PhpDocInfoFactory $phpDocInfoFactory */
|
||||
$phpDocInfo = $phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
|
||||
// then use any method you like
|
||||
$returnType = $phpDocInfo->getReturnType();
|
||||
// instance of "\PHPStan\Type\IntegerType"
|
||||
var_dump($returnType);
|
||||
```
|
||||
|
||||
## How to Remove node?
|
||||
|
||||
```php
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
|
||||
/** @var PhpDocInfo $phpDocInfo */
|
||||
$phpDocInfo->removeByType(ReturnTagValueNode::class);
|
||||
```
|
||||
|
||||
## How create PhpDocInfo for a new node?
|
||||
|
||||
In case you build a new node and want to work with its doc block, you need to create it first:
|
||||
|
||||
```php
|
||||
// the "PhpDocInfoFactory" service is already available in children of "AbstractRector"
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
|
||||
/** @var PhpDocInfoFactory $phpDocInfoFactory */
|
||||
$phpDocInfo = $phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
```
|
||||
|
||||
## How to get Param with Names and Types?
|
||||
|
||||
```php
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
|
||||
/** @var PhpDocInfo $phpDocInfo */
|
||||
$paramTypes = $phpDocInfo->getParamTypesByName();
|
||||
|
||||
/** @var array<string, Type> $paramTypes */
|
||||
var_dump($paramTypes);
|
||||
```
|
||||
|
||||
## How to Get Class Annotation?
|
||||
|
||||
Doctrine class annotations are annotations based on [`doctrine/annotations`](https://github.com/doctrine/annotations/) package. They are classes that have `@annotation`. Most common are Doctrine entity, column, one to many etc., but also Symfony route or Symfony validation annotations.
|
||||
|
||||
Let's look how to work one for Doctrine entity:
|
||||
|
||||
```php
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class UserEntity
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
|
||||
/** @var PhpDocInfo $phpDocInfo */
|
||||
$entityTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\ORM\Mapping\Entity');
|
||||
if (! $entityTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$annotationClass = $entityTagValueNode->getAnnotationClass();
|
||||
var_dump($annotationClass); // "Doctrine\ORM\Mapping\Entity"
|
||||
|
||||
$values = $entityTagValueNode->getValues();
|
||||
var_dump($values); // []
|
||||
```
|
98
vendor/rector/rector/docs/init_command.md
vendored
98
vendor/rector/rector/docs/init_command.md
vendored
|
@ -1,98 +0,0 @@
|
|||
# How to generate a configuration file
|
||||
|
||||
To start quickly you can run the init command
|
||||
|
||||
```bash
|
||||
vendor/bin/rector init
|
||||
```
|
||||
|
||||
This will create a `rector.php` if it doesn´t already exist in your root directory with some sensitive defaults to start with.
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// here we can define, what sets of rules will be applied
|
||||
$containerConfigurator->import(SetList::CODE_QUALITY);
|
||||
|
||||
// register single rule
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class);
|
||||
};
|
||||
```
|
||||
|
||||
The init command takes an option called `--template-type`.
|
||||
If some other Rector extension like [rector-nette](https://github.com/rectorphp/rector-nette) or [typo3-rector](https://github.com/sabbelasichon/typo3-rector) provides such a custom template type you can specify it here:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector init --template-type=typo3
|
||||
```
|
||||
|
||||
The rector.php file for TYPO3 contains useful framework specific defaults to start from:
|
||||
|
||||
```php
|
||||
use Ssch\TYPO3Rector\Set\Typo3SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Rector\PostRector\Rector\NameImportingPostRector;
|
||||
use Rector\Core\Configuration\Option;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// get parameters
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_76);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_87);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_95);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_104);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_11);
|
||||
|
||||
$parameters->set(Option::SKIP, [
|
||||
NameImportingPostRector::class => [
|
||||
'ClassAliasMap.php',
|
||||
'ext_localconf.php',
|
||||
'ext_emconf.php',
|
||||
'ext_tables.php',
|
||||
__DIR__ . '/**/Configuration/TCA/*',
|
||||
__DIR__ . '/**/Configuration/RequestMiddlewares.php',
|
||||
__DIR__ . '/**/Configuration/Commands.php',
|
||||
__DIR__ . '/**/Configuration/AjaxRoutes.php',
|
||||
__DIR__ . '/**/Configuration/Extbase/Persistence/Classes.php',
|
||||
],
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
If you just want to use the default template provided by Rector you can omit the --template-type option.
|
||||
|
||||
# How to add a template type as a developer
|
||||
In order to provide a new template type as a developer you should create a custom template class implementing the TemplateResolverInterface:
|
||||
|
||||
```php
|
||||
use Rector\Core\Contract\Template\TemplateResolverInterface;
|
||||
|
||||
final class MyCustomTemplate implements TemplateResolverInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const TYPE = 'custom';
|
||||
|
||||
public function provide(): string
|
||||
{
|
||||
return __DIR__ . '/path/to/custom/template.php.dist';
|
||||
}
|
||||
public function supports(string $type): bool
|
||||
{
|
||||
return $type === self::TYPE;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return self::TYPE;
|
||||
}
|
||||
}
|
||||
```
|
12291
vendor/rector/rector/docs/rector_rules_overview.md
vendored
12291
vendor/rector/rector/docs/rector_rules_overview.md
vendored
File diff suppressed because it is too large
Load Diff
|
@ -1,54 +0,0 @@
|
|||
# Static Reflection and Autoload
|
||||
|
||||
|
||||
Rector is using static reflection to load code without running it since version 0.10. That means your classes are found **without composer autoload and without running them**. Rector will find them and work with them as you have PSR-4 autoload properly setup. This comes very useful in legacy projects or projects with custom autoload.
|
||||
|
||||
Do you want to know more about it? Continue here:
|
||||
|
||||
- [From Doctrine Annotations Parser to Static Reflection](https://getrector.org/blog/from-doctrine-annotations-parser-to-static-reflection)
|
||||
- [Legacy Refactoring made Easy with Static Reflection](https://getrector.org/blog/2021/03/15/legacy-refactoring-made-easy-with-static-reflection)
|
||||
- [Zero Config Analysis with Static Reflection](https://phpstan.org/blog/zero-config-analysis-with-static-reflection) - from PHPStan
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// Rector is using static reflection to load code without running it - see https://phpstan.org/blog/zero-config-analysis-with-static-reflection
|
||||
$parameters->set(Option::AUTOLOAD_PATHS, [
|
||||
// discover specific file
|
||||
__DIR__ . '/file-with-functions.php',
|
||||
// or full directory
|
||||
__DIR__ . '/project-without-composer',
|
||||
]);
|
||||
```
|
||||
|
||||
## Include Files
|
||||
|
||||
Do you need to include constants, class aliases or custom autoloader? Use `BOOTSTRAP_FILES` parameter:
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::BOOTSTRAP_FILES, [
|
||||
__DIR__ . '/constants.php',
|
||||
__DIR__ . '/project/special/autoload.php',
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
Listed files will be executed like:
|
||||
|
||||
```php
|
||||
include $filePath;
|
||||
```
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Annotation;
|
||||
|
||||
final class AnnotationNaming
|
||||
{
|
||||
public function normalizeName(string $name) : string
|
||||
{
|
||||
return '@' . \ltrim($name, '@');
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Attributes;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
final class AttributeMirrorer
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const ATTRIBUTES_TO_MIRROR = [\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE];
|
||||
public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void
|
||||
{
|
||||
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
|
||||
if (!$oldNode->hasAttribute($attributeToMirror)) {
|
||||
continue;
|
||||
}
|
||||
$attributeValue = $oldNode->getAttribute($attributeToMirror);
|
||||
$newNode->setAttribute($attributeToMirror, $attributeValue);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Comment;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class CommentsMerger
|
||||
{
|
||||
/**
|
||||
* @var SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
public function __construct(\RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $mergedNodes
|
||||
*/
|
||||
public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void
|
||||
{
|
||||
$comments = $newNode->getComments();
|
||||
foreach ($mergedNodes as $mergedNode) {
|
||||
$comments = \array_merge($comments, $mergedNode->getComments());
|
||||
}
|
||||
if ($comments === []) {
|
||||
return;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
// remove so comments "win"
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null);
|
||||
}
|
||||
public function keepParent(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
{
|
||||
$parent = $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parent instanceof \PhpParser\Node) {
|
||||
return;
|
||||
}
|
||||
$phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
$comments = $parent->getComments();
|
||||
if ($phpDocInfo === null && $comments === []) {
|
||||
return;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
}
|
||||
public function keepChildren(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
{
|
||||
$childrenComments = $this->collectChildrenComments($oldNode);
|
||||
if ($childrenComments === []) {
|
||||
return;
|
||||
}
|
||||
$commentContent = '';
|
||||
foreach ($childrenComments as $childComment) {
|
||||
$commentContent .= $childComment->getText() . \PHP_EOL;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, [new \PhpParser\Comment($commentContent)]);
|
||||
}
|
||||
/**
|
||||
* @return Comment[]
|
||||
*/
|
||||
private function collectChildrenComments(\PhpParser\Node $node) : array
|
||||
{
|
||||
$childrenComments = [];
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) : void {
|
||||
$comments = $node->getComments();
|
||||
if ($comments !== []) {
|
||||
$childrenComments = \array_merge($childrenComments, $comments);
|
||||
}
|
||||
});
|
||||
return $childrenComments;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Contract;
|
||||
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
||||
interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface
|
||||
{
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\DataProvider;
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
final class CurrentTokenIteratorProvider
|
||||
{
|
||||
/**
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
|
||||
{
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
}
|
||||
public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
return $this->betterTokenIterator;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDoc;
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
||||
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $annotationClass;
|
||||
/**
|
||||
* @param array<mixed, mixed> $values
|
||||
*/
|
||||
public function __construct(
|
||||
// values
|
||||
string $annotationClass,
|
||||
?string $originalContent = null,
|
||||
array $values = [],
|
||||
?string $silentKey = null
|
||||
)
|
||||
{
|
||||
$this->hasChanged = \true;
|
||||
$this->annotationClass = $annotationClass;
|
||||
parent::__construct($values, $originalContent, $silentKey);
|
||||
}
|
||||
public function __toString() : string
|
||||
{
|
||||
if (!$this->hasChanged) {
|
||||
if ($this->originalContent === null) {
|
||||
return '';
|
||||
}
|
||||
return $this->originalContent;
|
||||
}
|
||||
if ($this->values === []) {
|
||||
if ($this->originalContent === '()') {
|
||||
// empty brackets
|
||||
return $this->originalContent;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
$itemContents = $this->printValuesContent($this->values);
|
||||
return \sprintf('(%s)', $itemContents);
|
||||
}
|
||||
public function getAnnotationClass() : string
|
||||
{
|
||||
return $this->annotationClass;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDoc;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
/**
|
||||
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
|
||||
* between the @ORM\Entity and (someContent)
|
||||
*/
|
||||
final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
|
||||
{
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->name . $this->value;
|
||||
}
|
||||
}
|
|
@ -1,444 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use RectorPrefix20210510\Nette\Utils\Strings;
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\Annotation\AnnotationNaming;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
||||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
/**
|
||||
* @template TNode as \PHPStan\PhpDocParser\Ast\Node
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfo\PhpDocInfoTest
|
||||
*/
|
||||
final class PhpDocInfo
|
||||
{
|
||||
/**
|
||||
* @var array<class-string<PhpDocTagValueNode>, string>
|
||||
*/
|
||||
private const TAGS_TYPES_TO_NAMES = [\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class => '@return', \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class => '@param', \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class => '@var', \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode::class => '@method', \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class => '@property'];
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isSingleLine = \false;
|
||||
/**
|
||||
* @var PhpDocNode
|
||||
*/
|
||||
private $phpDocNode;
|
||||
/**
|
||||
* @var PhpDocNode
|
||||
*/
|
||||
private $originalPhpDocNode;
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @var \PhpParser\Node
|
||||
*/
|
||||
private $node;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hasChanged = \false;
|
||||
/**
|
||||
* @var AnnotationNaming
|
||||
*/
|
||||
private $annotationNaming;
|
||||
/**
|
||||
* @var CurrentNodeProvider
|
||||
*/
|
||||
private $currentNodeProvider;
|
||||
/**
|
||||
* @var RectorChangeCollector
|
||||
*/
|
||||
private $rectorChangeCollector;
|
||||
/**
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
public function __construct(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->phpDocNode = $phpDocNode;
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
$this->originalPhpDocNode = clone $phpDocNode;
|
||||
if (!$betterTokenIterator->containsTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) {
|
||||
$this->isSingleLine = \true;
|
||||
}
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->node = $node;
|
||||
$this->annotationNaming = $annotationNaming;
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void
|
||||
{
|
||||
$this->phpDocNode->children[] = $phpDocChildNode;
|
||||
// to give node more space
|
||||
$this->makeMultiLined();
|
||||
$this->markAsChanged();
|
||||
}
|
||||
public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
{
|
||||
return $this->phpDocNode;
|
||||
}
|
||||
public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
{
|
||||
return $this->originalPhpDocNode;
|
||||
}
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTokens() : array
|
||||
{
|
||||
return $this->betterTokenIterator->getTokens();
|
||||
}
|
||||
public function getTokenCount() : int
|
||||
{
|
||||
return $this->betterTokenIterator->count();
|
||||
}
|
||||
public function getVarTagValueNode() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode
|
||||
{
|
||||
return $this->phpDocNode->getVarTagValues()[0] ?? null;
|
||||
}
|
||||
/**
|
||||
* @return array<PhpDocTagNode>
|
||||
*/
|
||||
public function getTagsByName(string $name) : array
|
||||
{
|
||||
$name = $this->annotationNaming->normalizeName($name);
|
||||
$tags = $this->phpDocNode->getTags();
|
||||
$tags = \array_filter($tags, function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($name) : bool {
|
||||
return $tag->name === $name;
|
||||
});
|
||||
$tags = \array_values($tags);
|
||||
return \array_values($tags);
|
||||
}
|
||||
public function getParamType(string $name) : \PHPStan\Type\Type
|
||||
{
|
||||
$paramTagValueNodes = $this->getParamTagValueByName($name);
|
||||
return $this->getTypeOrMixed($paramTagValueNodes);
|
||||
}
|
||||
/**
|
||||
* @return ParamTagValueNode[]
|
||||
*/
|
||||
public function getParamTagValueNodes() : array
|
||||
{
|
||||
return $this->phpDocNode->getParamTagValues();
|
||||
}
|
||||
public function getParamTagValueNodeByName(string $parameterName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
|
||||
continue;
|
||||
}
|
||||
return $paramTagValueNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getVarType() : \PHPStan\Type\Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getVarTagValueNode());
|
||||
}
|
||||
public function getReturnType() : \PHPStan\Type\Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getReturnTagValue());
|
||||
}
|
||||
/**
|
||||
* @param class-string<TNode> $type
|
||||
*/
|
||||
public function hasByType(string $type) : bool
|
||||
{
|
||||
return (bool) $this->getByType($type);
|
||||
}
|
||||
/**
|
||||
* @param array<class-string<TNode>> $types
|
||||
*/
|
||||
public function hasByTypes(array $types) : bool
|
||||
{
|
||||
foreach ($types as $type) {
|
||||
if ($this->hasByType($type)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param string[] $names
|
||||
*/
|
||||
public function hasByNames(array $names) : bool
|
||||
{
|
||||
foreach ($names as $name) {
|
||||
if ($this->hasByName($name)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function hasByName(string $name) : bool
|
||||
{
|
||||
return (bool) $this->getTagsByName($name);
|
||||
}
|
||||
public function getByName(string $name) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
{
|
||||
return $this->getTagsByName($name)[0] ?? null;
|
||||
}
|
||||
/**
|
||||
* @param string[] $classes
|
||||
*/
|
||||
public function getByAnnotationClasses(array $classes) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($classes as $class) {
|
||||
$tagValueNode = $this->getByAnnotationClass($class);
|
||||
if ($tagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return $tagValueNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function hasByAnnotationClass(string $class) : bool
|
||||
{
|
||||
return $this->getByAnnotationClass($class) !== null;
|
||||
}
|
||||
/**
|
||||
* @param string[] $annotationsClasses
|
||||
*/
|
||||
public function hasByAnnotationClasses(array $annotationsClasses) : bool
|
||||
{
|
||||
return $this->getByAnnotationClasses($annotationsClasses) !== null;
|
||||
}
|
||||
public function getByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
// new approach
|
||||
if (!$phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$annotationClass = $phpDocChildNode->value->getAnnotationClass();
|
||||
if ($annotationClass === $desiredClass) {
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
// fnmatch
|
||||
if ($this->isFnmatch($annotationClass, $desiredClass)) {
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param class-string<TNode> $type
|
||||
* @return TNode|null
|
||||
*/
|
||||
public function getByType(string $type)
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (\is_a($phpDocChildNode, $type, \true)) {
|
||||
return $phpDocChildNode;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
continue;
|
||||
}
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @deprecated, should accept only strings, to make it useful for developer who don't know internal logics of tag nodes; also not each tag requires node class
|
||||
* @template T of \PHPStan\PhpDocParser\Ast\Node
|
||||
* @param class-string<T> $type
|
||||
*/
|
||||
public function removeByType(string $type) : void
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if (\is_a($phpDocChildNode, $type, \true)) {
|
||||
unset($this->phpDocNode->children[$key]);
|
||||
$this->markAsChanged();
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
continue;
|
||||
}
|
||||
unset($this->phpDocNode->children[$key]);
|
||||
$this->markAsChanged();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return array<string, Type>
|
||||
*/
|
||||
public function getParamTypesByName() : array
|
||||
{
|
||||
$paramTypesByName = [];
|
||||
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||
$parameterName = $paramTagValueNode->parameterName;
|
||||
$paramTypesByName[$parameterName] = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($paramTagValueNode, $this->node);
|
||||
}
|
||||
return $paramTypesByName;
|
||||
}
|
||||
public function addTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : void
|
||||
{
|
||||
if ($phpDocTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@\\' . $phpDocTagValueNode->getAnnotationClass(), $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
return;
|
||||
}
|
||||
$name = $this->resolveNameForPhpDocTagValueNode($phpDocTagValueNode);
|
||||
$phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($phpDocTagNode);
|
||||
}
|
||||
public function isNewNode() : bool
|
||||
{
|
||||
if ($this->phpDocNode->children === []) {
|
||||
return \false;
|
||||
}
|
||||
return $this->betterTokenIterator->count() === 0;
|
||||
}
|
||||
public function makeSingleLined() : void
|
||||
{
|
||||
$this->isSingleLine = \true;
|
||||
}
|
||||
public function isSingleLine() : bool
|
||||
{
|
||||
return $this->isSingleLine;
|
||||
}
|
||||
public function hasInvalidTag(string $name) : bool
|
||||
{
|
||||
// fallback for invalid tag value node
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($phpDocChildNode->name !== $name) {
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode
|
||||
{
|
||||
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
|
||||
return $returnTagValueNodes[0] ?? null;
|
||||
}
|
||||
public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
{
|
||||
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
|
||||
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
|
||||
if ($paramTagValueNode->parameterName !== $desiredParamNameWithDollar) {
|
||||
continue;
|
||||
}
|
||||
return $paramTagValueNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return TemplateTagValueNode[]
|
||||
*/
|
||||
public function getTemplateTagValueNodes() : array
|
||||
{
|
||||
return $this->phpDocNode->getTemplateTagValues();
|
||||
}
|
||||
public function hasInheritDoc() : bool
|
||||
{
|
||||
return $this->hasByNames(['inheritdoc', 'inheritDoc']);
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
* Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed
|
||||
* Similar to missing original node in php-aprser
|
||||
*/
|
||||
public function markAsChanged() : void
|
||||
{
|
||||
$this->hasChanged = \true;
|
||||
$node = $this->currentNodeProvider->getNode();
|
||||
if ($node !== null) {
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($node);
|
||||
}
|
||||
}
|
||||
public function hasChanged() : bool
|
||||
{
|
||||
if ($this->isNewNode()) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->hasChanged) {
|
||||
return \true;
|
||||
}
|
||||
// has a single node with missing start_end
|
||||
$phpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor();
|
||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
|
||||
$phpDocNodeTraverser->traverse($this->phpDocNode);
|
||||
return $changedPhpDocNodeVisitor->hasChanged();
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMethodTagNames() : array
|
||||
{
|
||||
$methodTagNames = [];
|
||||
foreach ($this->phpDocNode->getMethodTagValues() as $methodTagValueNode) {
|
||||
$methodTagNames[] = $methodTagValueNode->methodName;
|
||||
}
|
||||
return $methodTagNames;
|
||||
}
|
||||
public function makeMultiLined() : void
|
||||
{
|
||||
$this->isSingleLine = \false;
|
||||
}
|
||||
private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : \PHPStan\Type\Type
|
||||
{
|
||||
if ($phpDocTagValueNode === null) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
}
|
||||
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
|
||||
}
|
||||
private function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : string
|
||||
{
|
||||
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
|
||||
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
|
||||
if (\is_a($phpDocTagValueNode, $tagValueNodeType, \true)) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($phpDocTagValueNode));
|
||||
}
|
||||
private function isFnmatch(string $currentValue, string $desiredValue) : bool
|
||||
{
|
||||
if (!\RectorPrefix20210510\Nette\Utils\Strings::contains($desiredValue, '*')) {
|
||||
return \false;
|
||||
}
|
||||
return \fnmatch($desiredValue, $currentValue, \FNM_NOESCAPE);
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
||||
use Rector\BetterPhpDocParser\Annotation\AnnotationNaming;
|
||||
use Rector\BetterPhpDocParser\Contract\PhpDocNodeFactoryInterface;
|
||||
use Rector\BetterPhpDocParser\PhpDocNodeMapper;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
||||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class PhpDocInfoFactory
|
||||
{
|
||||
/**
|
||||
* @var PhpDocParser
|
||||
*/
|
||||
private $betterPhpDocParser;
|
||||
/**
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
/**
|
||||
* @var CurrentNodeProvider
|
||||
*/
|
||||
private $currentNodeProvider;
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @var PhpDocNodeMapper
|
||||
*/
|
||||
private $phpDocNodeMapper;
|
||||
/**
|
||||
* @var AnnotationNaming
|
||||
*/
|
||||
private $annotationNaming;
|
||||
/**
|
||||
* @var RectorChangeCollector
|
||||
*/
|
||||
private $rectorChangeCollector;
|
||||
/**
|
||||
* @var array<string, PhpDocInfo>
|
||||
*/
|
||||
private $phpDocInfosByObjectHash = [];
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeMapper $phpDocNodeMapper, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \PHPStan\PhpDocParser\Lexer\Lexer $lexer, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser $betterPhpDocParser, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->betterPhpDocParser = $betterPhpDocParser;
|
||||
$this->lexer = $lexer;
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->phpDocNodeMapper = $phpDocNodeMapper;
|
||||
$this->annotationNaming = $annotationNaming;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
// already added
|
||||
$phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||
return $phpDocInfo;
|
||||
}
|
||||
$phpDocInfo = $this->createFromNode($node);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||
return $phpDocInfo;
|
||||
}
|
||||
return $this->createEmpty($node);
|
||||
}
|
||||
public function createFromNode(\PhpParser\Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$objectHash = \spl_object_hash($node);
|
||||
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
|
||||
return $this->phpDocInfosByObjectHash[$objectHash];
|
||||
}
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
$docComment = $node->getDocComment();
|
||||
if (!$docComment instanceof \PhpParser\Comment\Doc) {
|
||||
if ($node->getComments() !== []) {
|
||||
return null;
|
||||
}
|
||||
// create empty node
|
||||
$content = '';
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
} else {
|
||||
$content = $docComment->getText();
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
|
||||
$this->setPositionOfLastToken($phpDocNode);
|
||||
}
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, $tokenIterator, $node);
|
||||
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
|
||||
return $phpDocInfo;
|
||||
}
|
||||
public function createEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node);
|
||||
// multiline by default
|
||||
$phpDocInfo->makeMultiLined();
|
||||
return $phpDocInfo;
|
||||
}
|
||||
/**
|
||||
* Needed for printing
|
||||
*/
|
||||
private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
||||
{
|
||||
if ($phpDocNode->children === []) {
|
||||
return;
|
||||
}
|
||||
$phpDocChildNodes = $phpDocNode->children;
|
||||
$lastChildNode = \array_pop($phpDocChildNodes);
|
||||
$startAndEnd = $lastChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
||||
}
|
||||
}
|
||||
private function createFromPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator);
|
||||
$phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector);
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
return $phpDocInfo;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class TokenIteratorFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const INDEX = 'index';
|
||||
/**
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
/**
|
||||
* @var PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(\PHPStan\PhpDocParser\Lexer\Lexer $lexer, \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
return new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
}
|
||||
public function createFromTokenIterator(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
if ($tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
|
||||
return $tokenIterator;
|
||||
}
|
||||
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
|
||||
$betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
// keep original position
|
||||
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'index');
|
||||
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);
|
||||
return $betterTokenIterator;
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use RectorPrefix20210510\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher;
|
||||
final class PhpDocClassRenamer
|
||||
{
|
||||
/**
|
||||
* @var ClassAnnotationMatcher
|
||||
*/
|
||||
private $classAnnotationMatcher;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher)
|
||||
{
|
||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||
}
|
||||
/**
|
||||
* Covers annotations like @ORM, @Serializer, @Assert etc
|
||||
* See https://github.com/rectorphp/rector/issues/1872
|
||||
*
|
||||
* @param string[] $oldToNewClasses
|
||||
*/
|
||||
public function changeTypeInAnnotationTypes(\PhpParser\Node $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
|
||||
{
|
||||
$this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
||||
$this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processAssertChoiceTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$assertChoiceTagValueNode = $phpDocInfo->getByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
|
||||
if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
|
||||
if ($callback === null) {
|
||||
return;
|
||||
}
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
if ($callback[0] !== $oldClass) {
|
||||
continue;
|
||||
}
|
||||
$callback[0] = $newClass;
|
||||
$assertChoiceTagValueNode->changeValue('callback', $callback);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineRelationTagValueNode(\PhpParser\Node $node, array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']);
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processSerializerTypeTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
$className = $doctrineAnnotationTagValueNode->getSilentValue();
|
||||
if ($className) {
|
||||
if ($className === $oldClass) {
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
||||
continue;
|
||||
}
|
||||
$newContent = \RectorPrefix20210510\Nette\Utils\Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
||||
if ($newContent === $className) {
|
||||
continue;
|
||||
}
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newContent);
|
||||
continue;
|
||||
}
|
||||
$currentType = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type');
|
||||
if ($currentType === $oldClass) {
|
||||
$doctrineAnnotationTagValueNode->changeValue('type', $newClass);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node $node, array $oldToNewClasses) : void
|
||||
{
|
||||
if ($doctrineAnnotationTagValueNode->getAnnotationClass() === 'Doctrine\\ORM\\Mapping\\Embedded') {
|
||||
$classKey = 'class';
|
||||
} else {
|
||||
$classKey = 'targetEntity';
|
||||
}
|
||||
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey);
|
||||
if ($targetEntity === null) {
|
||||
return;
|
||||
}
|
||||
// resolve to FQN
|
||||
$tagFullyQualifiedName = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($targetEntity, $node);
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
if ($tagFullyQualifiedName !== $oldClass) {
|
||||
continue;
|
||||
}
|
||||
$doctrineAnnotationTagValueNode->changeValue($classKey, $newClass);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
final class PhpDocTagRemover
|
||||
{
|
||||
public function removeByName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $name) : void
|
||||
{
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
$tagClass = $phpDocChildNode->value->getAnnotationClass();
|
||||
if ($tagClass === $name) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function removeTagValueFromNode(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\PhpDocParser\Ast\Node $desiredNode) : void
|
||||
{
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if ($phpDocChildNode === $desiredNode) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($phpDocChildNode->value !== $desiredNode) {
|
||||
continue;
|
||||
}
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
}
|
||||
private function areAnnotationNamesEqual(string $firstAnnotationName, string $secondAnnotationName) : bool
|
||||
{
|
||||
$firstAnnotationName = \trim($firstAnnotationName, '@');
|
||||
$secondAnnotationName = \trim($secondAnnotationName, '@');
|
||||
return $firstAnnotationName === $secondAnnotationName;
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use PhpParser\Node\Param;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\Type\Constant\ConstantArrayType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\NeverType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory;
|
||||
final class PhpDocTypeChanger
|
||||
{
|
||||
/**
|
||||
* @var TypeComparator
|
||||
*/
|
||||
private $typeComparator;
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
/**
|
||||
* @var ParamPhpDocNodeFactory
|
||||
*/
|
||||
private $paramPhpDocNodeFactory;
|
||||
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory $paramPhpDocNodeFactory)
|
||||
{
|
||||
$this->typeComparator = $typeComparator;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->paramPhpDocNodeFactory = $paramPhpDocNodeFactory;
|
||||
}
|
||||
public function changeVarType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void
|
||||
{
|
||||
// better skip, could crash hard
|
||||
if ($phpDocInfo->hasInvalidTag('@var')) {
|
||||
return;
|
||||
}
|
||||
// make sure the tags are not identical, e.g imported class vs FQN class
|
||||
if ($this->typeComparator->areTypesEqual($phpDocInfo->getVarType(), $newType)) {
|
||||
return;
|
||||
}
|
||||
// prevent existing type override by mixed
|
||||
if (!$phpDocInfo->getVarType() instanceof \PHPStan\Type\MixedType && $newType instanceof \PHPStan\Type\Constant\ConstantArrayType && $newType->getItemType() instanceof \PHPStan\Type\NeverType) {
|
||||
return;
|
||||
}
|
||||
// override existing type
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
||||
$currentVarTagValueNode = $phpDocInfo->getVarTagValueNode();
|
||||
if ($currentVarTagValueNode !== null) {
|
||||
// only change type
|
||||
$currentVarTagValueNode->type = $newPHPStanPhpDocType;
|
||||
} else {
|
||||
// add completely new one
|
||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($newPHPStanPhpDocType, '', '');
|
||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||
}
|
||||
}
|
||||
public function changeReturnType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void
|
||||
{
|
||||
// better not touch this, can crash
|
||||
if ($phpDocInfo->hasInvalidTag('@return')) {
|
||||
return;
|
||||
}
|
||||
// make sure the tags are not identical, e.g imported class vs FQN class
|
||||
if ($this->typeComparator->areTypesEqual($phpDocInfo->getReturnType(), $newType)) {
|
||||
return;
|
||||
}
|
||||
// override existing type
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
||||
$currentReturnTagValueNode = $phpDocInfo->getReturnTagValue();
|
||||
if ($currentReturnTagValueNode !== null) {
|
||||
// only change type
|
||||
$currentReturnTagValueNode->type = $newPHPStanPhpDocType;
|
||||
} else {
|
||||
// add completely new one
|
||||
$returnTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($newPHPStanPhpDocType, '');
|
||||
$phpDocInfo->addTagValueNode($returnTagValueNode);
|
||||
}
|
||||
}
|
||||
public function changeParamType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType, \PhpParser\Node\Param $param, string $paramName) : void
|
||||
{
|
||||
// better skip, could crash hard
|
||||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||
return;
|
||||
}
|
||||
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
||||
// override existing type
|
||||
if ($paramTagValueNode !== null) {
|
||||
// already set
|
||||
$currentType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $param);
|
||||
// avoid overriding better type
|
||||
if ($this->typeComparator->isSubtype($currentType, $newType)) {
|
||||
return;
|
||||
}
|
||||
if ($this->typeComparator->areTypesEqual($currentType, $newType)) {
|
||||
return;
|
||||
}
|
||||
$paramTagValueNode->type = $phpDocType;
|
||||
} else {
|
||||
$paramTagValueNode = $this->paramPhpDocNodeFactory->create($phpDocType, $param);
|
||||
$phpDocInfo->addTagValueNode($paramTagValueNode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
use Rector\Naming\ValueObject\ParamRename;
|
||||
final class PropertyDocBlockManipulator
|
||||
{
|
||||
/**
|
||||
* @var PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
/**
|
||||
* @param ParamRename $renameValueObject
|
||||
*/
|
||||
public function renameParameterNameInDocBlock(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : void
|
||||
{
|
||||
$functionLike = $renameValueObject->getFunctionLike();
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
|
||||
if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
|
||||
$paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class VarAnnotationManipulator
|
||||
{
|
||||
/**
|
||||
* @var PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @var PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
}
|
||||
public function decorateNodeWithInlineVarType(\PhpParser\Node $node, \PHPStan\Type\TypeWithClassName $typeWithClassName, string $variableName) : void
|
||||
{
|
||||
$phpDocInfo = $this->resolvePhpDocInfo($node);
|
||||
// already done
|
||||
if ($phpDocInfo->getVarTagValueNode() !== null) {
|
||||
return;
|
||||
}
|
||||
$fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
|
||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
|
||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||
$phpDocInfo->makeSingleLined();
|
||||
}
|
||||
public function decorateNodeWithType(\PhpParser\Node $node, \PHPStan\Type\Type $staticType) : void
|
||||
{
|
||||
if ($staticType instanceof \PHPStan\Type\MixedType) {
|
||||
return;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType);
|
||||
}
|
||||
private function resolvePhpDocInfo(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$currentStmt = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if ($currentStmt instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
|
||||
} else {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
}
|
||||
$phpDocInfo->makeSingleLined();
|
||||
return $phpDocInfo;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user