Updated Rector to commit 89511623cd

89511623cd update docs
This commit is contained in:
Tomas Votruba 2021-08-02 15:06:07 +00:00
parent 6d9e1da1ac
commit 0141b275c0
6 changed files with 24 additions and 197 deletions

View File

@ -1,4 +1,4 @@
# 494 Rules Overview
# 490 Rules Overview
<br>
@ -88,13 +88,13 @@
- [Removing](#removing) (6)
- [RemovingStatic](#removingstatic) (9)
- [RemovingStatic](#removingstatic) (8)
- [Renaming](#renaming) (11)
- [Restoration](#restoration) (6)
- [Transform](#transform) (37)
- [Transform](#transform) (34)
- [TypeDeclaration](#typedeclaration) (20)
@ -9322,7 +9322,7 @@ Change defined static service to dynamic one
public function run()
{
- SomeStaticMethod::someStatic();
+ $this->someStaticMethod::someStatic();
+ $this->someStaticMethod->someStatic();
}
}
```
@ -9341,7 +9341,7 @@ Change defined static service to dynamic one
public function run()
{
- SomeStaticMethod::$someStatic;
+ $this->someStaticMethod::$someStatic;
+ $this->someStaticMethod->someStatic;
}
}
```
@ -9422,58 +9422,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### PHPUnitStaticToKernelTestCaseGetRector
Convert static calls in PHPUnit test cases, to `get()` from the container of KernelTestCase
:wrench: **configure it!**
- class: [`Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector`](../rules/RemovingStatic/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector.php)
```php
use Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PHPUnitStaticToKernelTestCaseGetRector::class)
->call('configure', [[
PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => ['EntityFactory'],
]]);
};
```
```diff
-use PHPUnit\Framework\TestCase;
+use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
-final class SomeTestCase extends TestCase
+final class SomeTestCase extends KernelTestCase
{
+ /**
+ * @var EntityFactory
+ */
+ private $entityFactory;
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ $this->entityFactory = $this->getService(EntityFactory::class);
+ }
+
public function test()
{
- $product = EntityFactory::create('product');
+ $product = $this->entityFactory->create('product');
}
}
```
<br>
### PassFactoryToUniqueObjectRector
Convert new `X/Static::call()` to factories in entities, pass them via constructor to each other
@ -10659,27 +10607,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### FunctionToStaticMethodRector
Change functions to static calls, so composer can autoload them
- class: [`Rector\Transform\Rector\FileWithoutNamespace\FunctionToStaticMethodRector`](../rules/Transform/Rector/FileWithoutNamespace/FunctionToStaticMethodRector.php)
```diff
-function some_function()
+class SomeUtilsClass
{
+ public static function someFunction()
+ {
+ }
}
-some_function('lol');
+SomeUtilsClass::someFunction('lol');
```
<br>
### GetAndSetToMethodCallRector
Turns defined `__get`/`__set` to specific method calls.
@ -10875,52 +10802,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### MethodCallToReturnRector
Wrap method call to return
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\Expression\MethodCallToReturnRector`](../rules/Transform/Rector/Expression/MethodCallToReturnRector.php)
```php
use Rector\Transform\Rector\Expression\MethodCallToReturnRector;
use Rector\Transform\ValueObject\MethodCallToReturn;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(MethodCallToReturnRector::class)
->call('configure', [[
MethodCallToReturnRector::METHOD_CALL_WRAPS => ValueObjectInliner::inline([
new MethodCallToReturn('SomeClass', 'deny'),
]),
]]);
};
```
```diff
class SomeClass
{
public function run()
{
- $this->deny();
+ return $this->deny();
}
public function deny()
{
return 1;
}
}
```
<br>
### MethodCallToStaticCallRector
Change method call to desired static call
@ -11693,60 +11574,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### VariableMethodCallToServiceCallRector
Replace variable method call to a service one
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector`](../rules/Transform/Rector/MethodCall/VariableMethodCallToServiceCallRector.php)
```php
use Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector;
use Rector\Transform\ValueObject\VariableMethodCallToServiceCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(VariableMethodCallToServiceCallRector::class)
->call('configure', [[
VariableMethodCallToServiceCallRector::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => ValueObjectInliner::inline([
new VariableMethodCallToServiceCall(
'PhpParser\Node',
'getAttribute',
'php_doc_info',
'Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory',
'createFromNodeOrEmpty'
),
]),
]]);
};
```
```diff
+use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use PhpParser\Node;
class SomeClass
{
+ public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
+ {
+ $this->phpDocInfoFactory = $phpDocInfoFactory;
+ }
public function run(Node $node)
{
- $phpDocInfo = $node->getAttribute('php_doc_info');
+ $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
}
}
```
<br>
### WrapReturnRector
Wrap return value of specific method

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'f515dd655ea406522c2e2e6adbbb9cf93c72a4b7';
public const PACKAGE_VERSION = '89511623cddcaf3c2438b0e53b81f6b91e3549b1';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-02 16:46:52';
public const RELEASE_DATE = '2021-08-02 16:54:22';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210802\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5::getLoader();
return ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5
class ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463', '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\ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1dd9d88bbce07aa181fbe3e49b81ffc5($fileIdentifier, $file);
composerRequire507e2fbcb0a2d677ee90c77a41079463($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1dd9d88bbce07aa181fbe3e49b81ffc5($fileIdentifier, $file)
function composerRequire507e2fbcb0a2d677ee90c77a41079463($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5
class ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3841,9 +3841,9 @@ class ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1dd9d88bbce07aa181fbe3e49b81ffc5::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit507e2fbcb0a2d677ee90c77a41079463::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210802\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5', false) && !interface_exists('ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5', false) && !trait_exists('ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5', false)) {
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInit1dd9d88bbce07aa181fbe3e49b81ffc5');
if (!class_exists('ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463', false) && !interface_exists('ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463', false) && !trait_exists('ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463', false)) {
spl_autoload_call('RectorPrefix20210802\ComposerAutoloaderInit507e2fbcb0a2d677ee90c77a41079463');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210802\Doctrine\Inflector\Inflector');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210802\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire1dd9d88bbce07aa181fbe3e49b81ffc5')) {
function composerRequire1dd9d88bbce07aa181fbe3e49b81ffc5() {
return \RectorPrefix20210802\composerRequire1dd9d88bbce07aa181fbe3e49b81ffc5(...func_get_args());
if (!function_exists('composerRequire507e2fbcb0a2d677ee90c77a41079463')) {
function composerRequire507e2fbcb0a2d677ee90c77a41079463() {
return \RectorPrefix20210802\composerRequire507e2fbcb0a2d677ee90c77a41079463(...func_get_args());
}
}
if (!function_exists('parseArgs')) {