Skip to content

Commit

Permalink
Updated Rector to commit d1b7a49
Browse files Browse the repository at this point in the history
rectorphp/rector-src@d1b7a49 [DeadCode][Php73] Ensure return  only when changed on RemoveDuplicatedCaseInSwitchRector+RegexDashEscapeRector (#2462)
  • Loading branch information
TomasVotruba committed Jun 9, 2022
1 parent 63f3dad commit bfad534
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ public function refactor(Node $node) : ?Node
}
/** @var Case_|null $previousCase */
$previousCase = null;
$hasChanged = \false;
foreach ($node->cases as $case) {
if ($previousCase instanceof Case_ && $this->areSwitchStmtsEqualsAndWithBreak($case, $previousCase)) {
$previousCase->stmts = [];
$hasChanged = \true;
}
$previousCase = $case;
}
if (!$hasChanged) {
return null;
}
return $node;
}
private function areSwitchStmtsEqualsAndWithBreak(Case_ $currentCase, Case_ $previousCase) : bool
Expand Down
14 changes: 9 additions & 5 deletions rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ final class RegexDashEscapeRector extends AbstractRector implements MinPhpVersio
* @see https://regex101.com/r/TBVme9/8
*/
private const RIGHT_HAND_UNESCAPED_DASH_REGEX = '#(?<!\\[)-(\\\\(w|s|d)[.*]?)\\]#i';
/**
* @var bool
*/
private $hasChanged = \false;
/**
* @readonly
* @var \Rector\Core\Php\Regex\RegexPatternArgumentManipulator
Expand Down Expand Up @@ -78,18 +82,16 @@ public function refactor(Node $node) : ?Node
if ($regexArguments === []) {
return null;
}
$hasChanged = \false;
foreach ($regexArguments as $regexArgument) {
if (StringUtils::isMatch($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) {
continue;
}
$this->escapeStringNode($regexArgument);
$hasChanged = \true;
}
if ($hasChanged) {
return $node;
if (!$this->hasChanged) {
return null;
}
return null;
return $node;
}
private function escapeStringNode(String_ $string) : void
{
Expand All @@ -98,12 +100,14 @@ private function escapeStringNode(String_ $string) : void
$string->value = Strings::replace($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX, '$1\\-');
// helped needed to skip re-escaping regular expression
$string->setAttribute(AttributeKey::IS_REGULAR_PATTERN, \true);
$this->hasChanged = \true;
return;
}
if (StringUtils::isMatch($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX)) {
$string->value = Strings::replace($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX, '\\-$1]');
// helped needed to skip re-escaping regular expression
$string->setAttribute(AttributeKey::IS_REGULAR_PATTERN, \true);
$this->hasChanged = \true;
}
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'eaea281956949f03f3b6477dec89dd503099f632';
public const PACKAGE_VERSION = 'd1b7a49e35cd236f15ddb3010d2b91b065d094a5';
/**
* @var string
*/
public const RELEASE_DATE = '2022-06-09 11:41:42';
public const RELEASE_DATE = '2022-06-09 12:04:36';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

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

return ComposerAutoloaderInit0ae86684e1c6e6f76aa53acba93af3eb::getLoader();
return ComposerAutoloaderInitc3ec4e514d5835c03bacc44bd264930c::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit0ae86684e1c6e6f76aa53acba93af3eb
class ComposerAutoloaderInitc3ec4e514d5835c03bacc44bd264930c
{
private static $loader;

Expand All @@ -22,19 +22,19 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit0ae86684e1c6e6f76aa53acba93af3eb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitc3ec4e514d5835c03bacc44bd264930c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit0ae86684e1c6e6f76aa53acba93af3eb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitc3ec4e514d5835c03bacc44bd264930c', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$includeFiles = \Composer\Autoload\ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire0ae86684e1c6e6f76aa53acba93af3eb($fileIdentifier, $file);
composerRequirec3ec4e514d5835c03bacc44bd264930c($fileIdentifier, $file);
}

return $loader;
Expand All @@ -46,7 +46,7 @@ public static function getLoader()
* @param string $file
* @return void
*/
function composerRequire0ae86684e1c6e6f76aa53acba93af3eb($fileIdentifier, $file)
function composerRequirec3ec4e514d5835c03bacc44bd264930c($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb
class ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
Expand Down Expand Up @@ -3389,9 +3389,9 @@ class ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0ae86684e1c6e6f76aa53acba93af3eb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc3ec4e514d5835c03bacc44bd264930c::$classMap;

}, null, ClassLoader::class);
}
Expand Down
48 changes: 24 additions & 24 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1853,12 +1853,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-cakephp.git",
"reference": "7bc99a7caedb12817ef56443f6392ced53c54b56"
"reference": "f84ea17f1c0425b9947259917f9019496a62c527"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-cakephp\/zipball\/7bc99a7caedb12817ef56443f6392ced53c54b56",
"reference": "7bc99a7caedb12817ef56443f6392ced53c54b56",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-cakephp\/zipball\/f84ea17f1c0425b9947259917f9019496a62c527",
"reference": "f84ea17f1c0425b9947259917f9019496a62c527",
"shasum": ""
},
"require": {
Expand All @@ -1884,7 +1884,7 @@
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-06-05T07:36:25+00:00",
"time": "2022-06-09T09:55:22+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -1922,12 +1922,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "f5bf84ccdd110e2ce34ea0d28ae66aa98aa44c92"
"reference": "ac93c3f4103c986bc19aab8b871c6714b93c59b6"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/f5bf84ccdd110e2ce34ea0d28ae66aa98aa44c92",
"reference": "f5bf84ccdd110e2ce34ea0d28ae66aa98aa44c92",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/ac93c3f4103c986bc19aab8b871c6714b93c59b6",
"reference": "ac93c3f4103c986bc19aab8b871c6714b93c59b6",
"shasum": ""
},
"require": {
Expand All @@ -1952,7 +1952,7 @@
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-06-05T07:34:02+00:00",
"time": "2022-06-09T10:01:30+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -2066,12 +2066,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-laravel.git",
"reference": "25afcdb5f140f72a710783c3922b8080a381cc2c"
"reference": "5574246768866deeff6ee6c889a9263dbc3f678f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/25afcdb5f140f72a710783c3922b8080a381cc2c",
"reference": "25afcdb5f140f72a710783c3922b8080a381cc2c",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/5574246768866deeff6ee6c889a9263dbc3f678f",
"reference": "5574246768866deeff6ee6c889a9263dbc3f678f",
"shasum": ""
},
"require": {
Expand All @@ -2095,7 +2095,7 @@
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-06-05T07:28:06+00:00",
"time": "2022-06-09T09:54:30+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -2133,12 +2133,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-nette.git",
"reference": "4307b98001cfb0fcfcb7d730249c34488c347f96"
"reference": "f29fa56f8339bbea7b9deb6dd917335fce45b01f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/4307b98001cfb0fcfcb7d730249c34488c347f96",
"reference": "4307b98001cfb0fcfcb7d730249c34488c347f96",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/f29fa56f8339bbea7b9deb6dd917335fce45b01f",
"reference": "f29fa56f8339bbea7b9deb6dd917335fce45b01f",
"shasum": ""
},
"require": {
Expand Down Expand Up @@ -2170,7 +2170,7 @@
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-06-05T07:33:07+00:00",
"time": "2022-06-09T10:01:03+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -2211,12 +2211,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpoffice.git",
"reference": "29f4cf098107617b2d71da1542f7c74201212119"
"reference": "15ee440d27c52c552aae6a1bb4977afa6024c8eb"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpoffice\/zipball\/29f4cf098107617b2d71da1542f7c74201212119",
"reference": "29f4cf098107617b2d71da1542f7c74201212119",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpoffice\/zipball\/15ee440d27c52c552aae6a1bb4977afa6024c8eb",
"reference": "15ee440d27c52c552aae6a1bb4977afa6024c8eb",
"shasum": ""
},
"require": {
Expand All @@ -2240,7 +2240,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2022-06-05T07:37:45+00:00",
"time": "2022-06-09T10:01:56+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -2278,12 +2278,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "9d58f8ab076bb2e363c8f6426ac5328815ca63ca"
"reference": "e6ed24fc884b9ad71342d03f2c5eaaf1c00b9b0b"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/9d58f8ab076bb2e363c8f6426ac5328815ca63ca",
"reference": "9d58f8ab076bb2e363c8f6426ac5328815ca63ca",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/e6ed24fc884b9ad71342d03f2c5eaaf1c00b9b0b",
"reference": "e6ed24fc884b9ad71342d03f2c5eaaf1c00b9b0b",
"shasum": ""
},
"require": {
Expand All @@ -2308,7 +2308,7 @@
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-06-05T07:19:37+00:00",
"time": "2022-06-09T09:50:22+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
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 7bc99a7'), '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 f5bf84c'), '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 623c9e2'), '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 25afcdb'), '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 4307b98'), '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 29f4cf0'), '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 9d58f8a'), '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 36747ba'));
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 f84ea17'), '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 ac93c3f'), '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 623c9e2'), '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 5574246'), '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 f29fa56'), '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 15ee440'), '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 e6ed24f'), '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 36747ba'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ private function processToOneRelation(Property $property, DoctrineAnnotationTagV
}
// resolve to FQN
$tagFullyQualifiedName = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($targetEntity, $property);
if ($tagFullyQualifiedName === null) {
return new MixedType();
}
$fullyQualifiedObjectType = new FullyQualifiedObjectType($tagFullyQualifiedName);
$isNullable = $this->isNullableType($joinDoctrineAnnotationTagValueNode);
return $this->resolveFromObjectType($fullyQualifiedObjectType, $isNullable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ private function changeTypeInAttributeTypes(Property $property, bool $hasChanged
if ($fullyQualified === $value) {
continue;
}
if ($fullyQualified === null) {
continue;
}
$arg->value = $this->nodeFactory->createClassConstFetch($fullyQualified, 'class');
return $property;
}
Expand Down
Loading

0 comments on commit bfad534

Please sign in to comment.