mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
Updated Rector to commit 9d8e5c9011
9d8e5c9011
[CodingStyle] Remove UseMessageVariableForSprintfInSymfonyStyleRector as local custom rule (#1419)
This commit is contained in:
parent
a1da107d4b
commit
3c3c64edbd
|
@ -5,11 +5,9 @@ namespace RectorPrefix20211207;
|
|||
|
||||
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
};
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20211207;
|
||||
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
};
|
|
@ -21,7 +21,6 @@ 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;
|
||||
|
@ -57,7 +56,6 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
$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)->configure(['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 502 Rules Overview
|
||||
# 501 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
- [CodeQuality](#codequality) (70)
|
||||
|
||||
- [CodingStyle](#codingstyle) (35)
|
||||
- [CodingStyle](#codingstyle) (34)
|
||||
|
||||
- [Compatibility](#compatibility) (1)
|
||||
|
||||
|
@ -2471,28 +2471,6 @@ Use ++ increment instead of `$var += 1`
|
|||
|
||||
<br>
|
||||
|
||||
### UseMessageVariableForSprintfInSymfonyStyleRector
|
||||
|
||||
Decouple `$message` property from `sprintf()` calls in `$this->symfonyStyle->method()`
|
||||
|
||||
- class: [`Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector`](../rules/CodingStyle/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(SymfonyStyle $symfonyStyle)
|
||||
{
|
||||
- $symfonyStyle->info(sprintf('Hi %s', 'Tom'));
|
||||
+ $message = sprintf('Hi %s', 'Tom');
|
||||
+ $symfonyStyle->info($message);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### VarConstantCommentRector
|
||||
|
||||
Constant should have a `@var` comment with type
|
||||
|
|
|
@ -28,10 +28,6 @@ final class SetList implements \Rector\Set\Contract\SetListInterface
|
|||
* @var string
|
||||
*/
|
||||
public const CODING_STYLE = __DIR__ . '/../../../config/set/coding-style.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CODING_STYLE_ADVANCED = __DIR__ . '/../../../config/set/coding-style-advanced.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\UseMessageVariableForSprintfInSymfonyStyleRectorTest
|
||||
*/
|
||||
final class UseMessageVariableForSprintfInSymfonyStyleRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Decouple $message property from sprintf() calls in $this->symfonyStyle->method()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(SymfonyStyle $symfonyStyle)
|
||||
{
|
||||
$symfonyStyle->info(sprintf('Hi %s', 'Tom'));
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
final class SomeClass
|
||||
{
|
||||
public function run(SymfonyStyle $symfonyStyle)
|
||||
{
|
||||
$message = sprintf('Hi %s', 'Tom');
|
||||
$symfonyStyle->info($message);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Expr\MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Style\\SymfonyStyle'))) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($node->args[0])) {
|
||||
return null;
|
||||
}
|
||||
if (!$node->args[0] instanceof \PhpParser\Node\Arg) {
|
||||
return null;
|
||||
}
|
||||
$argValue = $node->args[0]->value;
|
||||
if (!$argValue instanceof \PhpParser\Node\Expr\FuncCall) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($argValue, 'sprintf')) {
|
||||
return null;
|
||||
}
|
||||
$messageVariable = new \PhpParser\Node\Expr\Variable('message');
|
||||
$assign = new \PhpParser\Node\Expr\Assign($messageVariable, $argValue);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
|
||||
if (!$node->args[0] instanceof \PhpParser\Node\Arg) {
|
||||
return null;
|
||||
}
|
||||
$node->args[0]->value = $messageVariable;
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '16f9dc7d004b52f5e584d7d1d200304e85fc191a';
|
||||
public const PACKAGE_VERSION = '9d8e5c9011aa75624b22461af9e13f57ede43af2';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-12-07 23:05:46';
|
||||
public const RELEASE_DATE = '2021-12-07 22:15:20';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211207\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d::getLoader();
|
||||
return ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -1575,7 +1575,6 @@ return array(
|
|||
'Rector\\CodingStyle\\Rector\\If_\\NullableCompareToNullRector' => $baseDir . '/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Include_\\FollowRequireByDirRector' => $baseDir . '/rules/CodingStyle/Rector/Include_/FollowRequireByDirRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\PreferThisOrSelfMethodCallRector' => $baseDir . '/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\UseMessageVariableForSprintfInSymfonyStyleRector' => $baseDir . '/rules/CodingStyle/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => $baseDir . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => $baseDir . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => $baseDir . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
|
|
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 ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d
|
||||
class ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405', '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\ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd216962b9897575b4048fe8dd22c9405::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitd216962b9897575b4048fe8dd22c9405::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiredb3fde126ad98378b46327ce0e3d058d($fileIdentifier, $file);
|
||||
composerRequired216962b9897575b4048fe8dd22c9405($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequiredb3fde126ad98378b46327ce0e3d058d($fileIdentifier, $file)
|
||||
function composerRequired216962b9897575b4048fe8dd22c9405($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d
|
||||
class ComposerStaticInitd216962b9897575b4048fe8dd22c9405
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -1972,7 +1972,6 @@ class ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d
|
|||
'Rector\\CodingStyle\\Rector\\If_\\NullableCompareToNullRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Include_\\FollowRequireByDirRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Include_/FollowRequireByDirRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\PreferThisOrSelfMethodCallRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\UseMessageVariableForSprintfInSymfonyStyleRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
|
@ -3787,9 +3786,9 @@ class ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitdb3fde126ad98378b46327ce0e3d058d::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd216962b9897575b4048fe8dd22c9405::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd216962b9897575b4048fe8dd22c9405::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd216962b9897575b4048fe8dd22c9405::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20211207\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d', false) && !interface_exists('ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d', false) && !trait_exists('ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d', false)) {
|
||||
spl_autoload_call('RectorPrefix20211207\ComposerAutoloaderInitdb3fde126ad98378b46327ce0e3d058d');
|
||||
if (!class_exists('ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405', false) && !interface_exists('ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405', false) && !trait_exists('ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405', false)) {
|
||||
spl_autoload_call('RectorPrefix20211207\ComposerAutoloaderInitd216962b9897575b4048fe8dd22c9405');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20211207\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20211207\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequiredb3fde126ad98378b46327ce0e3d058d')) {
|
||||
function composerRequiredb3fde126ad98378b46327ce0e3d058d() {
|
||||
return \RectorPrefix20211207\composerRequiredb3fde126ad98378b46327ce0e3d058d(...func_get_args());
|
||||
if (!function_exists('composerRequired216962b9897575b4048fe8dd22c9405')) {
|
||||
function composerRequired216962b9897575b4048fe8dd22c9405() {
|
||||
return \RectorPrefix20211207\composerRequired216962b9897575b4048fe8dd22c9405(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user