mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Updated Rector to commit fa073d4408
fa073d4408
[CodeQuality] Add SimplifyIfExactValueReturnValueRector (#2278)
This commit is contained in:
parent
d72f56e566
commit
9306ff041a
|
@ -1,4 +1,4 @@
|
|||
# 511 Rules Overview
|
||||
# 512 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
|||
|
||||
- [Arguments](#arguments) (5)
|
||||
|
||||
- [CodeQuality](#codequality) (71)
|
||||
- [CodeQuality](#codequality) (72)
|
||||
|
||||
- [CodingStyle](#codingstyle) (35)
|
||||
|
||||
|
@ -490,15 +490,9 @@ Change `array_push()` to direct variable assign
|
|||
- class: [`Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector`](../rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$items = [];
|
||||
- array_push($items, $item);
|
||||
+ $items[] = $item;
|
||||
}
|
||||
}
|
||||
$items = [];
|
||||
-array_push($items, $item);
|
||||
+$items[] = $item;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -1338,6 +1332,23 @@ Changes if/else for same value as assign to ternary
|
|||
|
||||
<br>
|
||||
|
||||
### SimplifyIfExactValueReturnValueRector
|
||||
|
||||
Changes compared to value and return of expr to direct return
|
||||
|
||||
- class: [`Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector`](../rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php)
|
||||
|
||||
```diff
|
||||
$value = 'something';
|
||||
-if ($value === 52) {
|
||||
- return $value;
|
||||
-}
|
||||
-
|
||||
return $value;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### SimplifyIfIssetToNullCoalescingRector
|
||||
|
||||
Simplify binary if to null coalesce
|
||||
|
@ -2068,45 +2079,43 @@ Order attributes by desired names
|
|||
|
||||
- class: [`Rector\CodingStyle\Rector\ClassMethod\OrderAttributesRector`](../rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php)
|
||||
|
||||
#### 1) Order by specific namespace
|
||||
|
||||
```php
|
||||
use Rector\CodingStyle\Rector\ClassMethod\OrderAttributesRector;
|
||||
use Rector\Config\RectorConfig;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(OrderAttributesRector::class, [Annotation\First::class, Annotation\Second::class]);
|
||||
$rectorConfig->ruleWithConfiguration(OrderAttributesRector::class, ['First', 'Second']);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
+#[Annotation\First]
|
||||
#[Annotation\Second]
|
||||
-#[Annotation\First]
|
||||
+#[First]
|
||||
#[Second]
|
||||
-#[First]
|
||||
class Someclass
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
#### 2) Order alphabetically
|
||||
<br>
|
||||
|
||||
```php
|
||||
use Rector\CodingStyle\Rector\ClassMethod\OrderAttributesRector;
|
||||
use Rector\Config\RectorConfig;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(OrderAttributesRector::class, [Rector\CodingStyle\Rector\ClassMethod::ALPHABETICALLY]);
|
||||
$rectorConfig->ruleWithConfiguration(OrderAttributesRector::class, ['alphabetically']);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
+#[Annotation\AAttribute]
|
||||
#[Annotation\BAttribute]
|
||||
-#[Annotation\AAttribute]
|
||||
+#[AAttribute]
|
||||
#[BAttribute]
|
||||
-#[AAttribute]
|
||||
class Someclass
|
||||
{
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodeQuality\Rector\If_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector\SimplifyIfNullableReturnRectorTest
|
||||
*/
|
||||
final class SimplifyIfExactValueReturnValueRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeManipulator\IfManipulator
|
||||
*/
|
||||
private $ifManipulator;
|
||||
public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator)
|
||||
{
|
||||
$this->ifManipulator = $ifManipulator;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes compared to value and return of expr to direct return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
$value = 'something';
|
||||
if ($value === 52) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$value = 'something';
|
||||
return $value;
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Stmt\If_::class];
|
||||
}
|
||||
/**
|
||||
* @param If_ $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\Return_
|
||||
{
|
||||
$comparedNode = $this->ifManipulator->matchIfValueReturnValue($node);
|
||||
if ($comparedNode !== null) {
|
||||
$nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeComparator->areNodesEqual($comparedNode, $nextNode->expr)) {
|
||||
return null;
|
||||
}
|
||||
$this->removeNode($nextNode);
|
||||
return clone $nextNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
|||
namespace Rector\CodeQuality\Rector\If_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
|
@ -51,7 +52,7 @@ CODE_SAMPLE
|
|||
/**
|
||||
* @param If_ $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt
|
||||
{
|
||||
$comparedNode = $this->ifManipulator->matchIfNotNullReturnValue($node);
|
||||
if ($comparedNode !== null) {
|
||||
|
@ -69,18 +70,6 @@ CODE_SAMPLE
|
|||
$this->removeNode($nextNode);
|
||||
return $insideIfNode;
|
||||
}
|
||||
$comparedNode = $this->ifManipulator->matchIfValueReturnValue($node);
|
||||
if ($comparedNode !== null) {
|
||||
$nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeComparator->areNodesEqual($comparedNode, $nextNode->expr)) {
|
||||
return null;
|
||||
}
|
||||
$this->removeNode($nextNode);
|
||||
return clone $nextNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '30f2f9190987a0209e3e4aad209cce622c47595d';
|
||||
public const PACKAGE_VERSION = 'fa073d440863d477d2ee844c1dfb6bf481a2ff1f';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-05-10 14:31:56';
|
||||
public const RELEASE_DATE = '2022-05-10 18:08:30';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65::getLoader();
|
||||
return ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -1534,6 +1534,7 @@ return array(
|
|||
'Rector\\CodeQuality\\Rector\\If_\\ExplicitBoolCompareRector' => $baseDir . '/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ShortenElseIfRector' => $baseDir . '/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfElseToTernaryRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfExactValueReturnValueRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfIssetToNullCoalescingRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNotNullReturnRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNullableReturnRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.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 ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65
|
||||
class ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit278accc5d485536ec8986e1a90eefdc6::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit278accc5d485536ec8986e1a90eefdc6::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirecaf03d2e221f9712ba4ca112f15f3b65($fileIdentifier, $file);
|
||||
composerRequire278accc5d485536ec8986e1a90eefdc6($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequirecaf03d2e221f9712ba4ca112f15f3b65($fileIdentifier, $file)
|
||||
function composerRequire278accc5d485536ec8986e1a90eefdc6($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65
|
||||
class ComposerStaticInit278accc5d485536ec8986e1a90eefdc6
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
|
@ -1903,6 +1903,7 @@ class ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65
|
|||
'Rector\\CodeQuality\\Rector\\If_\\ExplicitBoolCompareRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ShortenElseIfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfElseToTernaryRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfExactValueReturnValueRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfIssetToNullCoalescingRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNotNullReturnRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNullableReturnRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php',
|
||||
|
@ -3886,9 +3887,9 @@ class ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcaf03d2e221f9712ba4ca112f15f3b65::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit278accc5d485536ec8986e1a90eefdc6::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit278accc5d485536ec8986e1a90eefdc6::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit278accc5d485536ec8986e1a90eefdc6::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -2576,12 +2576,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "0dd840beea0647c5b9e4e7c7a39c5d2056b6213b"
|
||||
"reference": "666c8d7da56c3fa9506c12f2d9f130f2accd2712"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/0dd840beea0647c5b9e4e7c7a39c5d2056b6213b",
|
||||
"reference": "0dd840beea0647c5b9e4e7c7a39c5d2056b6213b",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/666c8d7da56c3fa9506c12f2d9f130f2accd2712",
|
||||
"reference": "666c8d7da56c3fa9506c12f2d9f130f2accd2712",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2606,7 +2606,7 @@
|
|||
"symplify\/rule-doc-generator": "^10.0",
|
||||
"symplify\/vendor-patches": "^10.0"
|
||||
},
|
||||
"time": "2022-04-30T09:00:43+00:00",
|
||||
"time": "2022-05-10T12:53:13+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b59802f'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 77c17ba'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6d0fcdc'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e048bfd'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0dd840b'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 642ada3'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8d62a8b'));
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b59802f'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 77c17ba'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 784271e'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6d0fcdc'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e048bfd'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e544f2a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 666c8d7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 642ada3'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8d62a8b'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,16 +29,17 @@ final class IdentifierManipulator
|
|||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
/**
|
||||
* @param string[] $renameMethodMap
|
||||
* @param array<string, string> $renameMethodMap
|
||||
* @param \PhpParser\Node\Expr\ClassConstFetch|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod $node
|
||||
*/
|
||||
public function renameNodeWithMap($node, array $renameMethodMap) : void
|
||||
public function renameNodeWithMap($node, array $renameMethodMap) : bool
|
||||
{
|
||||
$oldNodeMethodName = $this->resolveOldMethodName($node);
|
||||
if ($oldNodeMethodName === null) {
|
||||
return;
|
||||
if (!\is_string($oldNodeMethodName)) {
|
||||
return \false;
|
||||
}
|
||||
$node->name = new \PhpParser\Node\Identifier($renameMethodMap[$oldNodeMethodName]);
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\ClassConstFetch|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod $node
|
||||
|
|
|
@ -49,7 +49,7 @@ final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector
|
|||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertEquals(2, $result, "message");', '$this->assertSame(2, $result, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertEquals($aString, $result, "message");', '$this->assertSame($aString, $result, "message");')]);
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertEquals(2, $result);', '$this->assertSame(2, $result);')]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
|
@ -70,16 +70,16 @@ final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector
|
|||
if (!$this->isNames($node->name, $methodNames)) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($node->args[0])) {
|
||||
$args = $node->getArgs();
|
||||
if (!isset($args[0])) {
|
||||
return null;
|
||||
}
|
||||
$valueNode = $node->args[0];
|
||||
$valueNodeType = $this->nodeTypeResolver->getType($valueNode->value);
|
||||
$valueNodeType = $this->nodeTypeResolver->getType($args[0]->value);
|
||||
if (!$this->isScalarType($valueNodeType)) {
|
||||
return null;
|
||||
}
|
||||
$this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP);
|
||||
return $node;
|
||||
$hasChanged = $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP);
|
||||
return $hasChanged ? $node : null;
|
||||
}
|
||||
private function isScalarType(\PHPStan\Type\Type $valueNodeType) : bool
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ final class AssertFalseStrposToContainsRector extends \Rector\Core\Rector\Abstra
|
|||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(strpos($anything, "foo"), "message");', '$this->assertNotContains("foo", $anything, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertNotFalse(stripos($anything, "foo"), "message");', '$this->assertContains("foo", $anything, "message");')]);
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(strpos($anything, "foo"), "message");', '$this->assertNotContains("foo", $anything, "message");')]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
|
@ -70,12 +70,12 @@ final class AssertFalseStrposToContainsRector extends \Rector\Core\Rector\Abstra
|
|||
return $this->changeArgumentsOrder($node);
|
||||
}
|
||||
/**
|
||||
* @return MethodCall|StaticCall|null
|
||||
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node
|
||||
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null
|
||||
*/
|
||||
private function changeArgumentsOrder($node) : ?\PhpParser\Node
|
||||
private function changeArgumentsOrder($node)
|
||||
{
|
||||
$oldArguments = $node->args;
|
||||
$oldArguments = $node->getArgs();
|
||||
$strposFuncCallNode = $oldArguments[0]->value;
|
||||
if (!$strposFuncCallNode instanceof \PhpParser\Node\Expr\FuncCall) {
|
||||
return null;
|
||||
|
|
|
@ -45,7 +45,15 @@ final class AssertPropertyExistsRector extends \Rector\Core\Rector\AbstractRecto
|
|||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue(property_exists(new Class, "property"), "message");', '$this->assertClassHasAttribute("property", "Class", "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(property_exists(new Class, "property"), "message");', '$this->assertClassNotHasAttribute("property", "Class", "message");')]);
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
$this->assertFalse(property_exists(new Class, "property"));
|
||||
$this->assertTrue(property_exists(new Class, "property"));
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$this->assertClassHasAttribute("property", "Class");
|
||||
$this->assertClassNotHasAttribute("property", "Class");
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -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('RectorPrefix20220510\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65', false) && !interface_exists('ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65', false) && !trait_exists('ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65', false)) {
|
||||
spl_autoload_call('RectorPrefix20220510\ComposerAutoloaderInitcaf03d2e221f9712ba4ca112f15f3b65');
|
||||
if (!class_exists('ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6', false) && !interface_exists('ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6', false) && !trait_exists('ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6', false)) {
|
||||
spl_autoload_call('RectorPrefix20220510\ComposerAutoloaderInit278accc5d485536ec8986e1a90eefdc6');
|
||||
}
|
||||
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('RectorPrefix20220510\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20220510\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequirecaf03d2e221f9712ba4ca112f15f3b65')) {
|
||||
function composerRequirecaf03d2e221f9712ba4ca112f15f3b65() {
|
||||
return \RectorPrefix20220510\composerRequirecaf03d2e221f9712ba4ca112f15f3b65(...func_get_args());
|
||||
if (!function_exists('composerRequire278accc5d485536ec8986e1a90eefdc6')) {
|
||||
function composerRequire278accc5d485536ec8986e1a90eefdc6() {
|
||||
return \RectorPrefix20220510\composerRequire278accc5d485536ec8986e1a90eefdc6(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user