Updated Rector to commit 14eb72c7bb6edc4a6e80c73c722f54465d947531

14eb72c7bb [DeadCode] Handle used in assign return on RemoveUnusedPrivatePropertyRector (#5608)
This commit is contained in:
Tomas Votruba 2024-02-12 14:51:52 +00:00
parent 360f068804
commit a120574816
9 changed files with 33 additions and 94 deletions

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\TraitUse;
use PhpParser\NodeTraverser;
use PHPStan\Analyser\Scope;
@ -141,8 +142,8 @@ CODE_SAMPLE
}
private function removePropertyAssigns(Class_ $class, string $propertyName) : void
{
$this->traverseNodesWithCallable($class, function (Node $node) use($class, $propertyName) : ?int {
if (!$node instanceof Expression) {
$this->traverseNodesWithCallable($class, function (Node $node) use($class, $propertyName) {
if (!$node instanceof Expression && !$node instanceof Return_) {
return null;
}
if (!$node->expr instanceof Assign) {
@ -152,7 +153,11 @@ CODE_SAMPLE
if (!$this->propertyFetchFinder->isLocalPropertyFetchByName($assign->var, $class, $propertyName)) {
return null;
}
return NodeTraverser::REMOVE_NODE;
if ($node instanceof Expression) {
return NodeTraverser::REMOVE_NODE;
}
$node->expr = $node->expr->expr;
return $node;
});
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '5edb023974a55b0efee74dd9fe92b314dd521f2c';
public const PACKAGE_VERSION = '14eb72c7bb6edc4a6e80c73c722f54465d947531';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-12 09:59:33';
public const RELEASE_DATE = '2024-02-12 21:49:34';
/**
* @var int
*/

View File

@ -1679,12 +1679,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "0666cb118332cda97b9ab5bd55bc26885854a2c2"
"reference": "99da1d590539a3913594f5faea8e250255d2aa53"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/0666cb118332cda97b9ab5bd55bc26885854a2c2",
"reference": "0666cb118332cda97b9ab5bd55bc26885854a2c2",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/99da1d590539a3913594f5faea8e250255d2aa53",
"reference": "99da1d590539a3913594f5faea8e250255d2aa53",
"shasum": ""
},
"require": {
@ -1708,7 +1708,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-02-12T13:13:37+00:00",
"time": "2024-02-12T14:26:54+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1801,12 +1801,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "f091938e0b34c64acab524c2acff911cea769b57"
"reference": "cdbe3907cd64fe07de118b0b722d7d84802988d1"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/f091938e0b34c64acab524c2acff911cea769b57",
"reference": "f091938e0b34c64acab524c2acff911cea769b57",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/cdbe3907cd64fe07de118b0b722d7d84802988d1",
"reference": "cdbe3907cd64fe07de118b0b722d7d84802988d1",
"shasum": ""
},
"require": {
@ -1829,7 +1829,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-01-17T15:05:41+00:00",
"time": "2024-02-12T14:24:54+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1854,7 +1854,7 @@
"description": "Rector upgrades rules for PHPUnit",
"support": {
"issues": "https:\/\/github.com\/rectorphp\/rector-phpunit\/issues",
"source": "https:\/\/github.com\/rectorphp\/rector-phpunit\/tree\/0.19.1"
"source": "https:\/\/github.com\/rectorphp\/rector-phpunit\/tree\/main"
},
"install-path": "..\/rector\/rector-phpunit"
},
@ -1865,12 +1865,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "5a62f1739e6feb5463d95ed02063aae860d358e4"
"reference": "59edb6245e7fbdbe4913c354b6803da3eb7254ac"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5a62f1739e6feb5463d95ed02063aae860d358e4",
"reference": "5a62f1739e6feb5463d95ed02063aae860d358e4",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/59edb6245e7fbdbe4913c354b6803da3eb7254ac",
"reference": "59edb6245e7fbdbe4913c354b6803da3eb7254ac",
"shasum": ""
},
"require": {
@ -1899,7 +1899,7 @@
"tomasvotruba\/class-leak": "^0.2.6",
"tracy\/tracy": "^2.10"
},
"time": "2024-02-09T12:04:30+00:00",
"time": "2024-02-12T14:24:35+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1921,7 +1921,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\/1.0.0"
"source": "https:\/\/github.com\/rectorphp\/rector-symfony\/tree\/main"
},
"install-path": "..\/rector\/rector-symfony"
},

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 0666cb1'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 8d1aab2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main f091938'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5a62f17'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 99da1d5'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 8d1aab2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main cdbe390'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 59edb62'));
private function __construct()
{
}

View File

@ -1,8 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
return RectorConfig::configure()->withImportNames(\true, \true, \true, \true)->withPaths([__DIR__ . '/src', __DIR__ . '/rules', __DIR__ . '/tests'])->withSkip(['*/Source/*', '*/Fixture/*'])->withRootFiles()->withPhpSets()->withPreparedSets(\true, \true, \true, \true, \true, \true)->withConfiguredRule(StringClassNameToClassConstantRector::class, ['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']);

View File

@ -17,6 +17,11 @@ final class IdGeneratorAnnotationTransformer implements PropertyAnnotationTransf
* @var \Rector\Doctrine\CodeQuality\NodeFactory\ArrayItemNodeFactory
*/
private $arrayItemNodeFactory;
/**
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/3.0/reference/basic-mapping.html#identifier-generation-strategies
* @var string[]
*/
private const AVAILABLE_STRATEGIES = ['auto', 'sequence', 'identity', 'none', 'custom'];
public function __construct(ArrayItemNodeFactory $arrayItemNodeFactory)
{
$this->arrayItemNodeFactory = $arrayItemNodeFactory;
@ -47,8 +52,8 @@ final class IdGeneratorAnnotationTransformer implements PropertyAnnotationTransf
*/
private function normalizeStrategy(array $generator) : array
{
if (isset($generator[EntityMappingKey::STRATEGY]) && $generator[EntityMappingKey::STRATEGY] === 'auto') {
$generator[EntityMappingKey::STRATEGY] = 'AUTO';
if (isset($generator[EntityMappingKey::STRATEGY]) && \in_array($generator[EntityMappingKey::STRATEGY], self::AVAILABLE_STRATEGIES, \true)) {
$generator[EntityMappingKey::STRATEGY] = \strtoupper($generator[EntityMappingKey::STRATEGY]);
}
return $generator;
}

View File

@ -1,29 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->importNames();
$rectorConfig->removeUnusedImports();
$rectorConfig->paths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/rules', __DIR__ . '/rules-tests', __DIR__ . '/rector.php', __DIR__ . '/ecs.php']);
$rectorConfig->skip([
// for tests
'*/Source/*',
'*/Fixture/*',
'*/Expected/*',
// object types
StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/config', __DIR__ . '/src/NodeFinder/DataProviderClassMethodFinder.php'],
]);
$rectorConfig->sets([LevelSetList::UP_TO_PHP_82, SetList::DEAD_CODE, PHPUnitSetList::PHPUNIT_100, PHPUnitSetList::PHPUNIT_CODE_QUALITY, SetList::CODE_QUALITY, SetList::CODING_STYLE, SetList::EARLY_RETURN, SetList::NAMING, SetList::TYPE_DECLARATION, SetList::PRIVATIZATION]);
$rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
// keep unprefixed to protected from downgrade
'PHPUnit\\Framework\\*',
'Prophecy\\Prophet',
]);
};

View File

@ -1,34 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
return RectorConfig::configure()->withImportNames(\true, \true, \true, \true)->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/rules', __DIR__ . '/rules-tests'])->withRootFiles()->withSkip([
'*/Fixture/*',
'*/Source/*',
'*/Source*/*',
'*/tests/*/Fixture*/Expected/*',
StringClassNameToClassConstantRector::class => [__DIR__ . '/config'],
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class => [
// "data" => "datum" false positive
__DIR__ . '/src/Rector/ClassMethod/AddRouteAnnotationRector.php',
],
// marked as skipped
ReturnNeverTypeRector::class => ['*/tests/*'],
])->withConfiguredRule(StringClassNameToClassConstantRector::class, [
'Error',
'Exception',
'Symfony\\*',
'Twig_*',
'Twig*',
'Swift_*',
'Doctrine\\*',
// loaded from project itself
'Psr\\Container\\ContainerInterface',
'Symfony\\Component\\Routing\\RouterInterface',
'Symfony\\Component\\DependencyInjection\\Container',
])->withPhpSets()->withPreparedSets(\true, \true, \false, \true, \true, \true);