mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 0660b21ecec553393226003c16432a626e20f8ec
0660b21ece
[Php54] Add ArrayToShortArrayRector (#2615)
This commit is contained in:
parent
7a4cfee22c
commit
189f399cf2
|
@ -4,10 +4,12 @@ declare (strict_types=1);
|
|||
namespace RectorPrefix202207;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php54\Rector\Array_\ArrayToShortArrayRector;
|
||||
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
||||
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(ArrayToShortArrayRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']);
|
||||
$rectorConfig->rule(RemoveReferenceFromCallRector::class);
|
||||
$rectorConfig->rule(RemoveZeroBreakContinueRector::class);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 411 Rules Overview
|
||||
# 412 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
- [Php53](#php53) (3)
|
||||
|
||||
- [Php54](#php54) (2)
|
||||
- [Php54](#php54) (3)
|
||||
|
||||
- [Php55](#php55) (5)
|
||||
|
||||
|
@ -4592,6 +4592,25 @@ Use ?: instead of ?, where useful
|
|||
|
||||
## Php54
|
||||
|
||||
### ArrayToShortArrayRector
|
||||
|
||||
Array to short array
|
||||
|
||||
- class: [`Rector\Php54\Rector\Array_\ArrayToShortArrayRector`](../rules/Php54/Rector/Array_/ArrayToShortArrayRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
- return array();
|
||||
+ return [];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### RemoveReferenceFromCallRector
|
||||
|
||||
Remove & from function and method calls
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php54\Rector\Array_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\Php54\Rector\Array_\ArrayToShortArrayRector\ArrayToShortArrayRectorTest
|
||||
*/
|
||||
final class ArrayToShortArrayRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::SHORT_ARRAY;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Array to short array', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Array_::class];
|
||||
}
|
||||
/**
|
||||
* @param Array_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($node->getAttribute(AttributeKey::KIND) === Array_::KIND_SHORT) {
|
||||
return null;
|
||||
}
|
||||
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
$node->setAttribute(AttributeKey::KIND, Array_::KIND_SHORT);
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '25accb21425957d4da0db801465570e4c62014ff';
|
||||
public const PACKAGE_VERSION = '0660b21ecec553393226003c16432a626e20f8ec';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-07-03 13:16:49';
|
||||
public const RELEASE_DATE = '2022-07-03 13:35:02';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -40,6 +40,10 @@ final class PhpVersionFeature
|
|||
* @var int
|
||||
*/
|
||||
public const NO_REFERENCE_IN_ARG = \Rector\Core\ValueObject\PhpVersion::PHP_54;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public const SHORT_ARRAY = \Rector\Core\ValueObject\PhpVersion::PHP_54;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c::getLoader();
|
||||
return ComposerAutoloaderInit962f084182d33365088c47167dbd9d4a::getLoader();
|
||||
|
|
|
@ -2418,6 +2418,7 @@ return array(
|
|||
'Rector\\Php53\\Rector\\FuncCall\\DirNameFileConstantToDirConstantRector' => $baseDir . '/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php',
|
||||
'Rector\\Php53\\Rector\\Ternary\\TernaryToElvisRector' => $baseDir . '/rules/Php53/Rector/Ternary/TernaryToElvisRector.php',
|
||||
'Rector\\Php53\\Rector\\Variable\\ReplaceHttpServerVarsByServerRector' => $baseDir . '/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php',
|
||||
'Rector\\Php54\\Rector\\Array_\\ArrayToShortArrayRector' => $baseDir . '/rules/Php54/Rector/Array_/ArrayToShortArrayRector.php',
|
||||
'Rector\\Php54\\Rector\\Break_\\RemoveZeroBreakContinueRector' => $baseDir . '/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php',
|
||||
'Rector\\Php54\\Rector\\FuncCall\\RemoveReferenceFromCallRector' => $baseDir . '/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php',
|
||||
'Rector\\Php55\\Rector\\Class_\\ClassConstantToSelfClassRector' => $baseDir . '/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c
|
||||
class ComposerAutoloaderInit962f084182d33365088c47167dbd9d4a
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit962f084182d33365088c47167dbd9d4a', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit962f084182d33365088c47167dbd9d4a', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit962f084182d33365088c47167dbd9d4a::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit962f084182d33365088c47167dbd9d4a::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiree20b2e720a7a5d1cf900b8b5689d6b8c($fileIdentifier, $file);
|
||||
composerRequire962f084182d33365088c47167dbd9d4a($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInite20b2e720a7a5d1cf900b8b5689d6b8c
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiree20b2e720a7a5d1cf900b8b5689d6b8c($fileIdentifier, $file)
|
||||
function composerRequire962f084182d33365088c47167dbd9d4a($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c
|
||||
class ComposerStaticInit962f084182d33365088c47167dbd9d4a
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -2725,6 +2725,7 @@ class ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c
|
|||
'Rector\\Php53\\Rector\\FuncCall\\DirNameFileConstantToDirConstantRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php',
|
||||
'Rector\\Php53\\Rector\\Ternary\\TernaryToElvisRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/Ternary/TernaryToElvisRector.php',
|
||||
'Rector\\Php53\\Rector\\Variable\\ReplaceHttpServerVarsByServerRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php',
|
||||
'Rector\\Php54\\Rector\\Array_\\ArrayToShortArrayRector' => __DIR__ . '/../..' . '/rules/Php54/Rector/Array_/ArrayToShortArrayRector.php',
|
||||
'Rector\\Php54\\Rector\\Break_\\RemoveZeroBreakContinueRector' => __DIR__ . '/../..' . '/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php',
|
||||
'Rector\\Php54\\Rector\\FuncCall\\RemoveReferenceFromCallRector' => __DIR__ . '/../..' . '/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php',
|
||||
'Rector\\Php55\\Rector\\Class_\\ClassConstantToSelfClassRector' => __DIR__ . '/../..' . '/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php',
|
||||
|
@ -3414,9 +3415,9 @@ class ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite20b2e720a7a5d1cf900b8b5689d6b8c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue