mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Updated Rector to commit 7c937fa451
7c937fa451
[DeadCode] Skip do { } while() on RemoveUnreachableStatementRector (#601)
This commit is contained in:
parent
d5797c02f3
commit
2ece2f3537
|
@ -10,6 +10,7 @@ use PhpParser\Node\FunctionLike;
|
|||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Do_;
|
||||
use PhpParser\Node\Stmt\Else_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
|
@ -27,6 +28,10 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
*/
|
||||
final class RemoveUnreachableStatementRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var array<class-string<Node>>
|
||||
*/
|
||||
private const STMTS_WITH_IS_UNREACHABLE = [\PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\Do_::class];
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unreachable statements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
|
@ -68,10 +73,7 @@ CODE_SAMPLE
|
|||
}
|
||||
// might be PHPStan false positive, better skip
|
||||
$previousStatement = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT);
|
||||
if ($previousStatement instanceof \PhpParser\Node\Stmt\If_) {
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE, $previousStatement->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE));
|
||||
}
|
||||
if ($previousStatement instanceof \PhpParser\Node\Stmt\While_) {
|
||||
if ($previousStatement instanceof \PhpParser\Node\Stmt && \in_array(\get_class($previousStatement), self::STMTS_WITH_IS_UNREACHABLE, \true)) {
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE, $previousStatement->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE));
|
||||
}
|
||||
if (!$this->isUnreachable($node)) {
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f668ee22795708f9cec8184c338fd984a5a6ff6f';
|
||||
public const PACKAGE_VERSION = '7c937fa45102ed0ece7194b1d64da787de199a7d';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-08-05 14:38:06';
|
||||
public const RELEASE_DATE = '2021-08-05 17:03:26';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210805\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 ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f::getLoader();
|
||||
return ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2951,7 +2951,6 @@ return array(
|
|||
'Rector\\Symfony\\NodeFactory\\GetSubscribedEventsClassMethodFactory' => $vendorDir . '/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\OnLogoutClassMethodFactory' => $vendorDir . '/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\OnSuccessLogoutClassMethodFactory' => $vendorDir . '/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\RouteNameClassFactory' => $vendorDir . '/rector/rector-symfony/src/NodeFactory/RouteNameClassFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\ThisRenderFactory' => $vendorDir . '/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php',
|
||||
'Rector\\Symfony\\Rector\\BinaryOp\\ResponseStatusCodeRector' => $vendorDir . '/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassConstFetch\\ConsoleExceptionToErrorEventConstantRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.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 ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f
|
||||
class ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748', '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\ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1f47bfce2e8986017da5e92a9e4d5c5f($fileIdentifier, $file);
|
||||
composerRequire0dda2fa47ac01c7c5b95771ff65b8748($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire1f47bfce2e8986017da5e92a9e4d5c5f($fileIdentifier, $file)
|
||||
function composerRequire0dda2fa47ac01c7c5b95771ff65b8748($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 ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f
|
||||
class ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3311,7 +3311,6 @@ class ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f
|
|||
'Rector\\Symfony\\NodeFactory\\GetSubscribedEventsClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\OnLogoutClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\OnSuccessLogoutClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\RouteNameClassFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeFactory/RouteNameClassFactory.php',
|
||||
'Rector\\Symfony\\NodeFactory\\ThisRenderFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php',
|
||||
'Rector\\Symfony\\Rector\\BinaryOp\\ResponseStatusCodeRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassConstFetch\\ConsoleExceptionToErrorEventConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php',
|
||||
|
@ -3847,9 +3846,9 @@ class ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1f47bfce2e8986017da5e92a9e4d5c5f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0dda2fa47ac01c7c5b95771ff65b8748::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
32
vendor/composer/installed.json
vendored
32
vendor/composer/installed.json
vendored
|
@ -1225,17 +1225,17 @@
|
|||
},
|
||||
{
|
||||
"name": "rector\/rector-doctrine",
|
||||
"version": "0.11.14",
|
||||
"version_normalized": "0.11.14.0",
|
||||
"version": "0.11.15",
|
||||
"version_normalized": "0.11.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "4d0118dd6b88ccd7dd8be91e1a12e46440bbe6b9"
|
||||
"reference": "14bf31132fa8356596eb588ab51c22b125f7bed1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/4d0118dd6b88ccd7dd8be91e1a12e46440bbe6b9",
|
||||
"reference": "4d0118dd6b88ccd7dd8be91e1a12e46440bbe6b9",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/14bf31132fa8356596eb588ab51c22b125f7bed1",
|
||||
"reference": "14bf31132fa8356596eb588ab51c22b125f7bed1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1250,13 +1250,13 @@
|
|||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/phpstan-rules": "^0.3.2",
|
||||
"rector\/rector-generator": "^0.2",
|
||||
"rector\/rector-src": "dev-main#7195d1e",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-coding-standard": "^9.4",
|
||||
"symplify\/phpstan-extensions": "^9.4",
|
||||
"symplify\/phpstan-rules": "^9.4",
|
||||
"symplify\/rule-doc-generator": "^9.4"
|
||||
},
|
||||
"time": "2021-07-25T12:23:48+00:00",
|
||||
"time": "2021-08-05T16:04:57+00:00",
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -1281,7 +1281,7 @@
|
|||
"description": "Rector upgrades rules for Doctrine",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector-doctrine\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-doctrine\/tree\/0.11.14"
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-doctrine\/tree\/0.11.15"
|
||||
},
|
||||
"install-path": "..\/rector\/rector-doctrine"
|
||||
},
|
||||
|
@ -1535,17 +1535,17 @@
|
|||
},
|
||||
{
|
||||
"name": "rector\/rector-symfony",
|
||||
"version": "0.11.16",
|
||||
"version_normalized": "0.11.16.0",
|
||||
"version": "0.11.17",
|
||||
"version_normalized": "0.11.17.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "233d432d4e247401c1d168390813d0c61a411e8f"
|
||||
"reference": "788252640f3b4474df2cec6fb7ed8a050d05beed"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/233d432d4e247401c1d168390813d0c61a411e8f",
|
||||
"reference": "233d432d4e247401c1d168390813d0c61a411e8f",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/788252640f3b4474df2cec6fb7ed8a050d05beed",
|
||||
"reference": "788252640f3b4474df2cec6fb7ed8a050d05beed",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1559,7 +1559,7 @@
|
|||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"rector\/rector-phpstan-rules": "^0.3.3",
|
||||
"rector\/phpstan-rules": "^0.3.4",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symfony\/security-core": "^5.2",
|
||||
"symfony\/security-http": "^5.2",
|
||||
|
@ -1568,7 +1568,7 @@
|
|||
"symplify\/phpstan-rules": "^9.4",
|
||||
"symplify\/rule-doc-generator": "^9.4"
|
||||
},
|
||||
"time": "2021-07-25T12:27:02+00:00",
|
||||
"time": "2021-08-05T16:18:06+00:00",
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -1593,7 +1593,7 @@
|
|||
"description": "Rector upgrades rules for Symfony Framework",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/rectorphp\/rector-symfony\/issues",
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-symfony\/tree\/0.11.16"
|
||||
"source": "https:\/\/github.com\/rectorphp\/rector-symfony\/tree\/0.11.17"
|
||||
},
|
||||
"install-path": "..\/rector\/rector-symfony"
|
||||
},
|
||||
|
|
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' => '0.11.3'), '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' => '0.11.14'), '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' => '0.11.5'), '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' => '0.11.21'), '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' => '0.11.2'), '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' => '0.11.7'), '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' => '0.11.16'), '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' => 'v0.11.22'));
|
||||
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' => '0.11.3'), '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' => '0.11.15'), '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' => '0.11.5'), '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' => '0.11.21'), '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' => '0.11.2'), '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' => '0.11.7'), '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' => '0.11.17'), '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' => 'v0.11.22'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
2
vendor/rector/rector-doctrine/composer.json
vendored
2
vendor/rector/rector-doctrine/composer.json
vendored
|
@ -14,7 +14,7 @@
|
|||
"symplify\/phpstan-extensions": "^9.4",
|
||||
"symplify\/easy-coding-standard": "^9.4",
|
||||
"symplify\/rule-doc-generator": "^9.4",
|
||||
"rector\/rector-src": "dev-main#7195d1e",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"doctrine\/orm": "^2.9",
|
||||
"rector\/rector-generator": "^0.2"
|
||||
},
|
||||
|
|
8
vendor/rector/rector-doctrine/rector.php
vendored
8
vendor/rector/rector-doctrine/rector.php
vendored
|
@ -3,11 +3,19 @@
|
|||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210805;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::SKIP, [
|
||||
// for tests
|
||||
__DIR__ . '/tests/Rector/Class_/TranslationBehaviorRector/Source',
|
||||
]);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::DEAD_CODE);
|
||||
};
|
||||
|
|
|
@ -16,7 +16,6 @@ use PHPStan\Type\SubtractableType;
|
|||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\Doctrine\TypeAnalyzer\TypeFinder;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
final class EntityObjectTypeResolver
|
||||
{
|
||||
|
@ -28,19 +27,14 @@ final class EntityObjectTypeResolver
|
|||
* @var \Rector\Doctrine\TypeAnalyzer\TypeFinder
|
||||
*/
|
||||
private $typeFinder;
|
||||
/**
|
||||
* @var \Rector\NodeCollector\NodeCollector\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
/**
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\TypeAnalyzer\TypeFinder $typeFinder, \Rector\NodeCollector\NodeCollector\NodeRepository $nodeRepository, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\TypeAnalyzer\TypeFinder $typeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->typeFinder = $typeFinder;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
public function resolveFromRepositoryClass(\PhpParser\Node\Stmt\Class_ $repositoryClass) : \PHPStan\Type\SubtractableType
|
||||
|
|
|
@ -15,7 +15,6 @@ use PhpParser\Node\Stmt\Property;
|
|||
use PHPStan\Reflection\Php\PhpPropertyReflection;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
|
@ -29,19 +28,14 @@ final class SetterClassMethodAnalyzer
|
|||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @var \Rector\NodeCollector\NodeCollector\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
/**
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeCollector\NodeCollector\NodeRepository $nodeRepository, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
|
||||
public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
}
|
||||
public function matchNullalbeClassMethodProperty(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\Property
|
||||
|
|
|
@ -59,7 +59,6 @@ final class IssetDimFetchCleaner
|
|||
if (!$isset instanceof \PhpParser\Node\Expr\Isset_) {
|
||||
continue;
|
||||
}
|
||||
$issetParent = $isset->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
foreach ($isset->vars as $var) {
|
||||
$dimFetchValue = $this->matchArrayDimFetchValue($var, $paramVariable);
|
||||
if (!\is_string($dimFetchValue)) {
|
||||
|
|
|
@ -3,60 +3,32 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\PhpDocParser;
|
||||
|
||||
use RectorPrefix20210805\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\PhpDoc\ResolvedPhpDocBlock;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeCollector\NodeCollector\NodeRepository;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\TypeDeclaration\PhpDoc\ShortClassExpander;
|
||||
final class DoctrineDocBlockResolver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/doLRPw/1
|
||||
*/
|
||||
private const ORM_ENTITY_EMBEDDABLE_SHORT_ANNOTATION_REGEX = '#@ORM\\\\(Entity|Embeddable)#';
|
||||
/**
|
||||
* @var \Rector\NodeCollector\NodeCollector\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
/**
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @var \PHPStan\Reflection\ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
/**
|
||||
* @var \Rector\TypeDeclaration\PhpDoc\ShortClassExpander
|
||||
*/
|
||||
private $shortClassExpander;
|
||||
public function __construct(\Rector\NodeCollector\NodeCollector\NodeRepository $nodeRepository, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\PhpDoc\ShortClassExpander $shortClassExpander)
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\TypeDeclaration\PhpDoc\ShortClassExpander $shortClassExpander)
|
||||
{
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
$this->shortClassExpander = $shortClassExpander;
|
||||
}
|
||||
/**
|
||||
* @param Class_|string|mixed $class
|
||||
*/
|
||||
public function isDoctrineEntityClass($class) : bool
|
||||
public function isDoctrineEntityClass(\PhpParser\Node\Stmt\Class_ $class) : bool
|
||||
{
|
||||
if ($class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return $this->isDoctrineEntityClassNode($class);
|
||||
}
|
||||
if (\is_string($class)) {
|
||||
return $this->isStringClassEntity($class);
|
||||
}
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
return $phpDocInfo->hasByAnnotationClasses(['Doctrine\\ORM\\Mapping\\Entity', 'Doctrine\\ORM\\Mapping\\Embeddable']);
|
||||
}
|
||||
public function getTargetEntity(\PhpParser\Node\Stmt\Property $property) : ?string
|
||||
{
|
||||
|
@ -76,27 +48,4 @@ final class DoctrineDocBlockResolver
|
|||
}
|
||||
return $this->isDoctrineEntityClass($classLike);
|
||||
}
|
||||
private function isDoctrineEntityClassNode(\PhpParser\Node\Stmt\Class_ $class) : bool
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
return $phpDocInfo->hasByAnnotationClasses(['Doctrine\\ORM\\Mapping\\Entity', 'Doctrine\\ORM\\Mapping\\Embeddable']);
|
||||
}
|
||||
private function isStringClassEntity(string $class) : bool
|
||||
{
|
||||
if (!$this->reflectionProvider->hasClass($class)) {
|
||||
return \false;
|
||||
}
|
||||
/** @var class-string $class */
|
||||
$classNode = $this->nodeRepository->findClass($class);
|
||||
if ($classNode !== null) {
|
||||
return $this->isDoctrineEntityClass($classNode);
|
||||
}
|
||||
$classReflection = $this->reflectionProvider->getClass($class);
|
||||
$resolvedPhpDocBlock = $classReflection->getResolvedPhpDoc();
|
||||
if (!$resolvedPhpDocBlock instanceof \PHPStan\PhpDoc\ResolvedPhpDocBlock) {
|
||||
return \false;
|
||||
}
|
||||
// dummy check of 3rd party code without running it
|
||||
return (bool) \RectorPrefix20210805\Nette\Utils\Strings::match($resolvedPhpDocBlock->getPhpDocString(), self::ORM_ENTITY_EMBEDDABLE_SHORT_ANNOTATION_REGEX);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,9 +167,6 @@ CODE_SAMPLE
|
|||
$entityReferenceExpr = $node->args[1]->value;
|
||||
$this->removeNode($node);
|
||||
});
|
||||
if ($entityReferenceExpr === null) {
|
||||
return null;
|
||||
}
|
||||
return $entityReferenceExpr;
|
||||
}
|
||||
private function addRepositoryProperty(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr $entityReferenceExpr) : void
|
||||
|
|
|
@ -7,7 +7,6 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\NodeManipulator\ClassInsertManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
@ -139,8 +138,7 @@ CODE_SAMPLE
|
|||
// remove all tree-related properties and their getters and setters - it's handled by behavior trait
|
||||
$removedPropertyNames = [];
|
||||
foreach ($node->getProperties() as $property) {
|
||||
$propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
if (!$propertyPhpDocInfo->hasByAnnotationClasses(['Gedmo\\Mapping\\Annotation\\TreeLeft', 'Gedmo\\Mapping\\Annotation\\TreeRight', 'Gedmo\\Mapping\\Annotation\\TreeRoot', 'Gedmo\\Mapping\\Annotation\\TreeParent', 'Gedmo\\Mapping\\Annotation\\TreeLevel'])) {
|
||||
if (!$this->shouldRemoveProperty($property)) {
|
||||
continue;
|
||||
}
|
||||
/** @var string $propertyName */
|
||||
|
@ -151,8 +149,9 @@ CODE_SAMPLE
|
|||
$this->removeClassMethodsForProperties($node, $removedPropertyNames);
|
||||
return $node;
|
||||
}
|
||||
private function shouldRemoveProperty(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool
|
||||
private function shouldRemoveProperty(\PhpParser\Node\Stmt\Property $property) : bool
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
return $phpDocInfo->hasByAnnotationClasses(['Gedmo\\Mapping\\Annotation\\TreeLeft', 'Gedmo\\Mapping\\Annotation\\TreeRight', 'Gedmo\\Mapping\\Annotation\\TreeRoot', 'Gedmo\\Mapping\\Annotation\\TreeParent', 'Gedmo\\Mapping\\Annotation\\TreeLevel']);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,6 @@ use PHPStan\Type\ObjectType;
|
|||
use PHPStan\Type\TypeCombinator;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer;
|
||||
use Rector\Doctrine\NodeManipulator\PropertyTypeManipulator;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -21,10 +20,6 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
*/
|
||||
final class MakeEntityDateTimePropertyDateTimeInterfaceRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer
|
||||
*/
|
||||
private $setterClassMethodAnalyzer;
|
||||
/**
|
||||
* @var \Rector\Doctrine\NodeManipulator\PropertyTypeManipulator
|
||||
*/
|
||||
|
@ -33,9 +28,8 @@ final class MakeEntityDateTimePropertyDateTimeInterfaceRector extends \Rector\Co
|
|||
* @var \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer
|
||||
*/
|
||||
private $propertyTypeInferer;
|
||||
public function __construct(\Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer $setterClassMethodAnalyzer, \Rector\Doctrine\NodeManipulator\PropertyTypeManipulator $propertyTypeManipulator, \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer)
|
||||
public function __construct(\Rector\Doctrine\NodeManipulator\PropertyTypeManipulator $propertyTypeManipulator, \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer $propertyTypeInferer)
|
||||
{
|
||||
$this->setterClassMethodAnalyzer = $setterClassMethodAnalyzer;
|
||||
$this->propertyTypeManipulator = $propertyTypeManipulator;
|
||||
$this->propertyTypeInferer = $propertyTypeInferer;
|
||||
}
|
||||
|
|
2
vendor/rector/rector-symfony/composer.json
vendored
2
vendor/rector/rector-symfony/composer.json
vendored
|
@ -18,7 +18,7 @@
|
|||
"symplify\/easy-coding-standard": "^9.4",
|
||||
"symplify\/rule-doc-generator": "^9.4",
|
||||
"phpstan\/extension-installer": "^1.1",
|
||||
"rector\/rector-phpstan-rules": "^0.3.3"
|
||||
"rector\/phpstan-rules": "^0.3.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\NodeFactory;
|
||||
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\Symfony\Composer\ComposerNamespaceMatcher;
|
||||
use Rector\Symfony\ValueObject\ClassName;
|
||||
use Rector\Symfony\ValueObject\ConstantNameAndValue;
|
||||
use RectorPrefix20210805\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder;
|
||||
use RectorPrefix20210805\Symplify\Astral\ValueObject\NodeBuilder\NamespaceBuilder;
|
||||
final class RouteNameClassFactory
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\PhpParser\Node\NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
/**
|
||||
* @var \Rector\Symfony\Composer\ComposerNamespaceMatcher
|
||||
*/
|
||||
private $composerNamespaceMatcher;
|
||||
public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Symfony\Composer\ComposerNamespaceMatcher $composerNamespaceMatcher)
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->composerNamespaceMatcher = $composerNamespaceMatcher;
|
||||
}
|
||||
/**
|
||||
* @param ConstantNameAndValue[] $constantNamesAndValues
|
||||
*/
|
||||
public function create(array $constantNamesAndValues, string $fileLocation) : \PhpParser\Node\Stmt\Namespace_
|
||||
{
|
||||
$classBuilder = new \RectorPrefix20210805\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder(\Rector\Symfony\ValueObject\ClassName::ROUTE_CLASS_SHORT_NAME);
|
||||
$classBuilder->makeFinal();
|
||||
$namespaceName = $this->composerNamespaceMatcher->matchNamespaceForLocation($fileLocation);
|
||||
if ($namespaceName === null) {
|
||||
$namespaceName = \Rector\Symfony\ValueObject\ClassName::ROUTE_NAME_NAMESPACE;
|
||||
} else {
|
||||
$namespaceName .= '\\ValueObject\\Routing';
|
||||
}
|
||||
foreach ($constantNamesAndValues as $constantNameAndValue) {
|
||||
$classConst = $this->nodeFactory->createPublicClassConst($constantNameAndValue->getName(), $constantNameAndValue->getValue());
|
||||
$classBuilder->addStmt($classConst);
|
||||
}
|
||||
$namespaceBuilder = new \RectorPrefix20210805\Symplify\Astral\ValueObject\NodeBuilder\NamespaceBuilder($namespaceName);
|
||||
$namespaceBuilder->addStmt($classBuilder->getNode());
|
||||
return $namespaceBuilder->getNode();
|
||||
}
|
||||
}
|
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('RectorPrefix20210805\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f', false) && !interface_exists('ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f', false) && !trait_exists('ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f', false)) {
|
||||
spl_autoload_call('RectorPrefix20210805\ComposerAutoloaderInit1f47bfce2e8986017da5e92a9e4d5c5f');
|
||||
if (!class_exists('ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748', false) && !interface_exists('ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748', false) && !trait_exists('ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748', false)) {
|
||||
spl_autoload_call('RectorPrefix20210805\ComposerAutoloaderInit0dda2fa47ac01c7c5b95771ff65b8748');
|
||||
}
|
||||
if (!class_exists('AjaxLogin', false) && !interface_exists('AjaxLogin', false) && !trait_exists('AjaxLogin', false)) {
|
||||
spl_autoload_call('RectorPrefix20210805\AjaxLogin');
|
||||
|
@ -3305,9 +3305,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210805\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire1f47bfce2e8986017da5e92a9e4d5c5f')) {
|
||||
function composerRequire1f47bfce2e8986017da5e92a9e4d5c5f() {
|
||||
return \RectorPrefix20210805\composerRequire1f47bfce2e8986017da5e92a9e4d5c5f(...func_get_args());
|
||||
if (!function_exists('composerRequire0dda2fa47ac01c7c5b95771ff65b8748')) {
|
||||
function composerRequire0dda2fa47ac01c7c5b95771ff65b8748() {
|
||||
return \RectorPrefix20210805\composerRequire0dda2fa47ac01c7c5b95771ff65b8748(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user