Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit c4910df

Browse files
committed
Updated Rector to commit c18327824304401098f762d43e36d298a42f830e
rectorphp/rector@c183278 [DowngradePhp71] Allow downgrade negative offset string on variable/PropertyFetch/StaticPropertyFetch (#6311)
1 parent b119bdf commit c4910df

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
namespace Rector\DowngradePhp71\Rector\String_;
55

66
use PhpParser\Node;
7+
use PhpParser\Node\Expr;
78
use PhpParser\Node\Expr\ArrayDimFetch;
89
use PhpParser\Node\Expr\BinaryOp\Minus;
910
use PhpParser\Node\Expr\FuncCall;
11+
use PhpParser\Node\Expr\PropertyFetch;
12+
use PhpParser\Node\Expr\StaticPropertyFetch;
1013
use PhpParser\Node\Expr\UnaryMinus;
14+
use PhpParser\Node\Expr\Variable;
1115
use PhpParser\Node\Scalar\String_;
1216
use Rector\Core\Rector\AbstractRector;
1317
use Rector\NodeTypeResolver\Node\AttributeKey;
@@ -37,21 +41,24 @@ public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\Rul
3741
*/
3842
public function getNodeTypes() : array
3943
{
40-
return [\PhpParser\Node\Scalar\String_::class, \PhpParser\Node\Expr\FuncCall::class];
44+
return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Scalar\String_::class, \PhpParser\Node\Expr\Variable::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class];
4145
}
4246
/**
43-
* @param String_|FuncCall $node
47+
* @param FuncCall|String_|Variable|PropertyFetch|StaticPropertyFetch $node
4448
*/
4549
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
4650
{
47-
if ($node instanceof \PhpParser\Node\Scalar\String_) {
48-
return $this->processForString($node);
51+
if ($node instanceof \PhpParser\Node\Expr\FuncCall) {
52+
return $this->processForFuncCall($node);
4953
}
50-
return $this->processForFuncCall($node);
54+
return $this->processForStringOrVariableOrProperty($node);
5155
}
52-
private function processForString(\PhpParser\Node\Scalar\String_ $string) : ?\PhpParser\Node\Scalar\String_
56+
/**
57+
* @param String_|Variable|PropertyFetch|StaticPropertyFetch $expr
58+
*/
59+
private function processForStringOrVariableOrProperty(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr
5360
{
54-
$nextNode = $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
61+
$nextNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
5562
if (!$nextNode instanceof \PhpParser\Node\Expr\UnaryMinus) {
5663
return null;
5764
}
@@ -64,9 +71,9 @@ private function processForString(\PhpParser\Node\Scalar\String_ $string) : ?\Ph
6471
}
6572
/** @var UnaryMinus $dim */
6673
$dim = $parentOfNextNode->dim;
67-
$strlenFuncCall = $this->nodeFactory->createFuncCall('strlen', [$string]);
74+
$strlenFuncCall = $this->nodeFactory->createFuncCall('strlen', [$expr]);
6875
$parentOfNextNode->dim = new \PhpParser\Node\Expr\BinaryOp\Minus($strlenFuncCall, $dim->expr);
69-
return $string;
76+
return $expr;
7077
}
7178
private function processForFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall
7279
{

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615::getLoader();
7+
return ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f::getLoader();

vendor/composer/autoload_real.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615
5+
class ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f
66
{
77
private static $loader;
88

@@ -22,15 +22,15 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27-
spl_autoload_unregister(array('ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f', 'loadClassLoader'));
2828

2929
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
3030
if ($useStaticLoader) {
3131
require __DIR__ . '/autoload_static.php';
3232

33-
call_user_func(\Composer\Autoload\ComposerStaticInit247d0f66f55abcb846ba32fc10197615::getInitializer($loader));
33+
call_user_func(\Composer\Autoload\ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f::getInitializer($loader));
3434
} else {
3535
$classMap = require __DIR__ . '/autoload_classmap.php';
3636
if ($classMap) {
@@ -42,19 +42,19 @@ public static function getLoader()
4242
$loader->register(true);
4343

4444
if ($useStaticLoader) {
45-
$includeFiles = Composer\Autoload\ComposerStaticInit247d0f66f55abcb846ba32fc10197615::$files;
45+
$includeFiles = Composer\Autoload\ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f::$files;
4646
} else {
4747
$includeFiles = require __DIR__ . '/autoload_files.php';
4848
}
4949
foreach ($includeFiles as $fileIdentifier => $file) {
50-
composerRequire247d0f66f55abcb846ba32fc10197615($fileIdentifier, $file);
50+
composerRequire3389d29fa97d5fdf3f1befb78bed949f($fileIdentifier, $file);
5151
}
5252

5353
return $loader;
5454
}
5555
}
5656

57-
function composerRequire247d0f66f55abcb846ba32fc10197615($fileIdentifier, $file)
57+
function composerRequire3389d29fa97d5fdf3f1befb78bed949f($fileIdentifier, $file)
5858
{
5959
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
6060
require $file;

vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit247d0f66f55abcb846ba32fc10197615
7+
class ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f
88
{
99
public static $files = array (
1010
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@@ -3419,9 +3419,9 @@ class ComposerStaticInit247d0f66f55abcb846ba32fc10197615
34193419
public static function getInitializer(ClassLoader $loader)
34203420
{
34213421
return \Closure::bind(function () use ($loader) {
3422-
$loader->prefixLengthsPsr4 = ComposerStaticInit247d0f66f55abcb846ba32fc10197615::$prefixLengthsPsr4;
3423-
$loader->prefixDirsPsr4 = ComposerStaticInit247d0f66f55abcb846ba32fc10197615::$prefixDirsPsr4;
3424-
$loader->classMap = ComposerStaticInit247d0f66f55abcb846ba32fc10197615::$classMap;
3422+
$loader->prefixLengthsPsr4 = ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f::$prefixLengthsPsr4;
3423+
$loader->prefixDirsPsr4 = ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f::$prefixDirsPsr4;
3424+
$loader->classMap = ComposerStaticInit3389d29fa97d5fdf3f1befb78bed949f::$classMap;
34253425

34263426
}, null, ClassLoader::class);
34273427
}

vendor/scoper-autoload.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
2525
spl_autoload_call('RectorPrefix20210503\CheckoutEntityFactory');
2626
}
27-
if (!class_exists('ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615', false) && !interface_exists('ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615', false) && !trait_exists('ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615', false)) {
28-
spl_autoload_call('RectorPrefix20210503\ComposerAutoloaderInit247d0f66f55abcb846ba32fc10197615');
27+
if (!class_exists('ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f', false) && !interface_exists('ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f', false) && !trait_exists('ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f', false)) {
28+
spl_autoload_call('RectorPrefix20210503\ComposerAutoloaderInit3389d29fa97d5fdf3f1befb78bed949f');
2929
}
3030
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
3131
spl_autoload_call('RectorPrefix20210503\Doctrine\Inflector\Inflector');
@@ -82,9 +82,9 @@ function print_node() {
8282
return \RectorPrefix20210503\print_node(...func_get_args());
8383
}
8484
}
85-
if (!function_exists('composerRequire247d0f66f55abcb846ba32fc10197615')) {
86-
function composerRequire247d0f66f55abcb846ba32fc10197615() {
87-
return \RectorPrefix20210503\composerRequire247d0f66f55abcb846ba32fc10197615(...func_get_args());
85+
if (!function_exists('composerRequire3389d29fa97d5fdf3f1befb78bed949f')) {
86+
function composerRequire3389d29fa97d5fdf3f1befb78bed949f() {
87+
return \RectorPrefix20210503\composerRequire3389d29fa97d5fdf3f1befb78bed949f(...func_get_args());
8888
}
8989
}
9090
if (!function_exists('parseArgs')) {

0 commit comments

Comments
 (0)