mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-31 12:42:05 +01:00
Updated Rector to commit 71719b5e05ddb03c627a56c379b20a5829ddbe4f
71719b5e05
[Php70] Do not take side effect on IfToSpaceshipRector (#1696)
This commit is contained in:
parent
7a85fbdbd8
commit
4515eabbc8
@ -124,7 +124,7 @@ CODE_SAMPLE
|
||||
}
|
||||
private function processReturnSpaceship(\PhpParser\Node\Expr $firstValue, \PhpParser\Node\Expr $secondValue) : \PhpParser\Node\Stmt\Return_
|
||||
{
|
||||
if ($this->nextNode !== null) {
|
||||
if ($this->nextNode instanceof \PhpParser\Node\Stmt\Return_) {
|
||||
$this->removeNode($this->nextNode);
|
||||
}
|
||||
// spaceship ready!
|
||||
@ -145,11 +145,11 @@ CODE_SAMPLE
|
||||
if ($if->else !== null) {
|
||||
$this->processElse($if->else);
|
||||
} else {
|
||||
$this->nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if ($this->nextNode instanceof \PhpParser\Node\Stmt\Return_ && $this->nextNode->expr instanceof \PhpParser\Node\Expr\Ternary) {
|
||||
$nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if ($nextNode instanceof \PhpParser\Node\Stmt\Return_ && $nextNode->expr instanceof \PhpParser\Node\Expr\Ternary) {
|
||||
/** @var Ternary $ternary */
|
||||
$ternary = $this->nextNode->expr;
|
||||
$this->processTernary($ternary);
|
||||
$ternary = $nextNode->expr;
|
||||
$this->processTernary($ternary, $nextNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,10 +190,10 @@ CODE_SAMPLE
|
||||
/** @var Return_ $returnNode */
|
||||
$returnNode = $else->stmts[0];
|
||||
if ($returnNode->expr instanceof \PhpParser\Node\Expr\Ternary) {
|
||||
$this->processTernary($returnNode->expr);
|
||||
$this->processTernary($returnNode->expr, null);
|
||||
}
|
||||
}
|
||||
private function processTernary(\PhpParser\Node\Expr\Ternary $ternary) : void
|
||||
private function processTernary(\PhpParser\Node\Expr\Ternary $ternary, ?\PhpParser\Node\Stmt\Return_ $return) : void
|
||||
{
|
||||
if ($ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) {
|
||||
$this->firstValue = $ternary->cond->left;
|
||||
@ -202,6 +202,7 @@ CODE_SAMPLE
|
||||
$this->onSmaller = $this->valueResolver->getValue($ternary->if);
|
||||
}
|
||||
$this->onGreater = $this->valueResolver->getValue($ternary->else);
|
||||
$this->nextNode = $return;
|
||||
} elseif ($ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Greater) {
|
||||
$this->firstValue = $ternary->cond->right;
|
||||
$this->secondValue = $ternary->cond->left;
|
||||
@ -209,6 +210,7 @@ CODE_SAMPLE
|
||||
$this->onGreater = $this->valueResolver->getValue($ternary->if);
|
||||
}
|
||||
$this->onSmaller = $this->valueResolver->getValue($ternary->else);
|
||||
$this->nextNode = $return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ use Rector\Core\NodeManipulator\PropertyManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Privatization\NodeFactory\ClassConstantFactory;
|
||||
use Rector\Privatization\NodeReplacer\PropertyFetchWithConstFetchReplacer;
|
||||
use RectorPrefix20220118\Symplify\PHPStanRules\Reflection\PropertyAnalyzer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
@ -128,9 +127,6 @@ CODE_SAMPLE
|
||||
if ($property->attrGroups !== []) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->isObjectType($classLike, new \PHPStan\Type\ObjectType('PHP_CodeSniffer\\Sniffs\\Sniff'))) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
return $this->isObjectType($classLike, new \PHPStan\Type\ObjectType('PHP_CodeSniffer\\Sniffs\\Sniff'));
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '9d781bb466dae354125382ff73302c094acf0bf1';
|
||||
public const PACKAGE_VERSION = '71719b5e05ddb03c627a56c379b20a5829ddbe4f';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-01-18 11:23:54';
|
||||
public const RELEASE_DATE = '2022-01-18 16:37:45';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220118\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 ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee::getLoader();
|
||||
return ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0::getLoader();
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -1888,12 +1888,14 @@ return array(
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttrinationFinder' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\ConstructorAssignPropertyAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\EntityObjectTypeResolver' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\MethodCallNameOnTypeResolver' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\SetterClassMethodAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TargetEntityResolver' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TranslatablePropertyCollectorAndRemover' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ArrayCollectionAssignFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ConstructClassMethodFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ConstructorClassMethodAssignFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\EntityIdNodeFactory' => $vendorDir . '/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.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 ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
class ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0', '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\ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1a7fdf2dc5a09523f3e07d3a96ae45ee($fileIdentifier, $file);
|
||||
composerRequire15971da685a21759ea75cb1a52bfdcf0($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire1a7fdf2dc5a09523f3e07d3a96ae45ee($fileIdentifier, $file)
|
||||
function composerRequire15971da685a21759ea75cb1a52bfdcf0($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
class ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -2283,12 +2283,14 @@ class ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\AttrinationFinder' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\ConstructorAssignPropertyAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\EntityObjectTypeResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\MethodCallNameOnTypeResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\SetterClassMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TargetEntityResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php',
|
||||
'Rector\\Doctrine\\NodeAnalyzer\\TranslatablePropertyCollectorAndRemover' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ArrayCollectionAssignFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ConstructClassMethodFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\ConstructorClassMethodAssignFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php',
|
||||
'Rector\\Doctrine\\NodeFactory\\EntityIdNodeFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.php',
|
||||
@ -3870,9 +3872,9 @@ class ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1a7fdf2dc5a09523f3e07d3a96ae45ee::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit15971da685a21759ea75cb1a52bfdcf0::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -2165,12 +2165,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "22517c3f026c0e938fe0132c2d50af7c10168bac"
|
||||
"reference": "fbac1aba2f1afeee4bbf6500fb51329203f41da3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/22517c3f026c0e938fe0132c2d50af7c10168bac",
|
||||
"reference": "22517c3f026c0e938fe0132c2d50af7c10168bac",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/fbac1aba2f1afeee4bbf6500fb51329203f41da3",
|
||||
"reference": "fbac1aba2f1afeee4bbf6500fb51329203f41da3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2195,7 +2195,7 @@
|
||||
"symplify\/rule-doc-generator": "^10.0",
|
||||
"symplify\/vendor-patches": "^10.0"
|
||||
},
|
||||
"time": "2022-01-18T08:36:41+00:00",
|
||||
"time": "2022-01-18T14:42:11+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 d1fa93d'), '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 22517c3'), '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 df58e86'), '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 6bee428'), '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 fbfa93c'), '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 f23c4bf'), '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 5a8c2a8'), '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 57743a8'), '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 d4a362b'));
|
||||
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 d1fa93d'), '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 fbac1ab'), '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 df58e86'), '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 6bee428'), '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 fbfa93c'), '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 f23c4bf'), '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 5a8c2a8'), '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 57743a8'), '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 d4a362b'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
1
vendor/rector/rector-doctrine/rector.php
vendored
1
vendor/rector/rector-doctrine/rector.php
vendored
@ -14,6 +14,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::SKIP, [
|
||||
// for tests
|
||||
'*/Source/*',
|
||||
|
@ -82,7 +82,7 @@ final class AttributeFinder
|
||||
* @param class-string[] $attributeClasses
|
||||
* @param \PhpParser\Node\Param|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $node
|
||||
*/
|
||||
private function findAttributeByClasses($node, array $attributeClasses) : ?\PhpParser\Node\Attribute
|
||||
public function findAttributeByClasses($node, array $attributeClasses) : ?\PhpParser\Node\Attribute
|
||||
{
|
||||
foreach ($attributeClasses as $attributeClass) {
|
||||
$attribute = $this->findAttributeByClass($node, $attributeClass);
|
||||
|
55
vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php
vendored
Normal file
55
vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
final class AttrinationFinder
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\NodeAnalyzer\AttributeFinder
|
||||
*/
|
||||
private $attributeFinder;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->attributeFinder = $attributeFinder;
|
||||
}
|
||||
/**
|
||||
* @param class-string $name
|
||||
* @param \PhpParser\Node\Param|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $node
|
||||
*/
|
||||
public function hasByOne($node, string $name) : bool
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo && $phpDocInfo->hasByAnnotationClass($name)) {
|
||||
return \true;
|
||||
}
|
||||
$attribute = $this->attributeFinder->findAttributeByClass($node, $name);
|
||||
return $attribute instanceof \PhpParser\Node\Attribute;
|
||||
}
|
||||
/**
|
||||
* @param class-string[] $names
|
||||
*/
|
||||
public function hasByMany(\PhpParser\Node\Stmt\Property $property, array $names) : bool
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($property);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo && $phpDocInfo->hasByAnnotationClasses($names)) {
|
||||
return \true;
|
||||
}
|
||||
$attribute = $this->attributeFinder->findAttributeByClasses($property, $names);
|
||||
return $attribute instanceof \PhpParser\Node\Attribute;
|
||||
}
|
||||
}
|
29
vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php
vendored
Normal file
29
vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Doctrine\NodeFactory;
|
||||
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
final class ArrayCollectionAssignFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory)
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
public function createFromPropertyName(string $toManyPropertyName) : \PhpParser\Node\Stmt\Expression
|
||||
{
|
||||
$propertyFetch = $this->nodeFactory->createPropertyFetch('this', $toManyPropertyName);
|
||||
$new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection'));
|
||||
$assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $new);
|
||||
return new \PhpParser\Node\Stmt\Expression($assign);
|
||||
}
|
||||
}
|
@ -4,13 +4,12 @@ declare (strict_types=1);
|
||||
namespace Rector\Doctrine\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\NodeManipulator\ClassDependencyManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Doctrine\NodeAnalyzer\AttrinationFinder;
|
||||
use Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -21,14 +20,30 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
*/
|
||||
final class InitializeDefaultEntityCollectionRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var class-string[]
|
||||
*/
|
||||
private const TO_MANY_ANNOTATION_CLASSES = ['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany'];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeManipulator\ClassDependencyManipulator
|
||||
*/
|
||||
private $classDependencyManipulator;
|
||||
public function __construct(\Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory
|
||||
*/
|
||||
private $arrayCollectionAssignFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Doctrine\NodeAnalyzer\AttrinationFinder
|
||||
*/
|
||||
private $attrinationFinder;
|
||||
public function __construct(\Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator, \Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory $arrayCollectionAssignFactory, \Rector\Doctrine\NodeAnalyzer\AttrinationFinder $attrinationFinder)
|
||||
{
|
||||
$this->classDependencyManipulator = $classDependencyManipulator;
|
||||
$this->arrayCollectionAssignFactory = $arrayCollectionAssignFactory;
|
||||
$this->attrinationFinder = $attrinationFinder;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -83,18 +98,10 @@ CODE_SAMPLE
|
||||
if ($kind === 'initialized') {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
if (!$phpDocInfo->hasByAnnotationClass('Doctrine\\ORM\\Mapping\\Entity')) {
|
||||
if (!$this->attrinationFinder->hasByOne($node, 'Doctrine\\ORM\\Mapping\\Entity')) {
|
||||
return null;
|
||||
}
|
||||
$toManyPropertyNames = $this->resolveToManyPropertyNames($node);
|
||||
if ($toManyPropertyNames === []) {
|
||||
return null;
|
||||
}
|
||||
$assigns = $this->createAssignsOfArrayCollectionsForPropertyNames($toManyPropertyNames);
|
||||
$this->classDependencyManipulator->addStmtsToConstructorIfNotThereYet($node, $assigns);
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, 'initialized');
|
||||
return $node;
|
||||
return $this->refactorClass($node);
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
@ -106,9 +113,7 @@ CODE_SAMPLE
|
||||
if (\count($property->props) !== 1) {
|
||||
continue;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
$hasToManyNode = $phpDocInfo->hasByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany']);
|
||||
if (!$hasToManyNode) {
|
||||
if (!$this->attrinationFinder->hasByMany($property, self::TO_MANY_ANNOTATION_CLASSES)) {
|
||||
continue;
|
||||
}
|
||||
/** @var string $propertyName */
|
||||
@ -125,15 +130,22 @@ CODE_SAMPLE
|
||||
{
|
||||
$assigns = [];
|
||||
foreach ($propertyNames as $propertyName) {
|
||||
$assigns[] = $this->createPropertyArrayCollectionAssign($propertyName);
|
||||
$assigns[] = $this->arrayCollectionAssignFactory->createFromPropertyName($propertyName);
|
||||
}
|
||||
return $assigns;
|
||||
}
|
||||
private function createPropertyArrayCollectionAssign(string $toManyPropertyName) : \PhpParser\Node\Stmt\Expression
|
||||
/**
|
||||
* @return \PhpParser\Node\Stmt\Class_|null
|
||||
*/
|
||||
private function refactorClass(\PhpParser\Node\Stmt\Class_ $class)
|
||||
{
|
||||
$propertyFetch = $this->nodeFactory->createPropertyFetch('this', $toManyPropertyName);
|
||||
$new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection'));
|
||||
$assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $new);
|
||||
return new \PhpParser\Node\Stmt\Expression($assign);
|
||||
$toManyPropertyNames = $this->resolveToManyPropertyNames($class);
|
||||
if ($toManyPropertyNames === []) {
|
||||
return null;
|
||||
}
|
||||
$assigns = $this->createAssignsOfArrayCollectionsForPropertyNames($toManyPropertyNames);
|
||||
$this->classDependencyManipulator->addStmtsToConstructorIfNotThereYet($class, $assigns);
|
||||
$class->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, 'initialized');
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
|
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('RectorPrefix20220118\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee', false) && !interface_exists('ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee', false) && !trait_exists('ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee', false)) {
|
||||
spl_autoload_call('RectorPrefix20220118\ComposerAutoloaderInit1a7fdf2dc5a09523f3e07d3a96ae45ee');
|
||||
if (!class_exists('ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0', false) && !interface_exists('ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0', false) && !trait_exists('ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0', false)) {
|
||||
spl_autoload_call('RectorPrefix20220118\ComposerAutoloaderInit15971da685a21759ea75cb1a52bfdcf0');
|
||||
}
|
||||
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('RectorPrefix20220118\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220118\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire1a7fdf2dc5a09523f3e07d3a96ae45ee')) {
|
||||
function composerRequire1a7fdf2dc5a09523f3e07d3a96ae45ee() {
|
||||
return \RectorPrefix20220118\composerRequire1a7fdf2dc5a09523f3e07d3a96ae45ee(...func_get_args());
|
||||
if (!function_exists('composerRequire15971da685a21759ea75cb1a52bfdcf0')) {
|
||||
function composerRequire15971da685a21759ea75cb1a52bfdcf0() {
|
||||
return \RectorPrefix20220118\composerRequire15971da685a21759ea75cb1a52bfdcf0(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user