Updated Rector to commit a26bfd9d12ee70f47ed522356d4fcad248a548a0

a26bfd9d12 [BetterPhpDocParser] Use str_contains() for DoctrineAnnotationDecorator (#6671) (#6674)
This commit is contained in:
Tomas Votruba 2025-01-17 14:52:45 +00:00
parent ec96ec3645
commit 47104446ae
7 changed files with 96 additions and 7 deletions

View File

@ -1831,6 +1831,7 @@ return array(
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\AddProphecyTraitRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\PublicDataProviderClassMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/PublicDataProviderClassMethodRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\StaticDataProviderClassMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\MethodCall\\PropertyExistsWithoutAssertRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\MethodCall\\RemoveSetMethodsMethodCallRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\StmtsAwareInterface\\ExpectsMethodCallDecorator' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\StmtsAwareInterface\\WithConsecutiveRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php',

View File

@ -2050,6 +2050,7 @@ class ComposerStaticInit4349f48e2d711e343a1bf0101d0ae855
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\AddProphecyTraitRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\PublicDataProviderClassMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/PublicDataProviderClassMethodRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\Class_\\StaticDataProviderClassMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/Class_/StaticDataProviderClassMethodRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\MethodCall\\PropertyExistsWithoutAssertRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\MethodCall\\RemoveSetMethodsMethodCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\StmtsAwareInterface\\ExpectsMethodCallDecorator' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/StmtsAwareInterface/ExpectsMethodCallDecorator.php',
'Rector\\PHPUnit\\PHPUnit100\\Rector\\StmtsAwareInterface\\WithConsecutiveRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php',

View File

@ -1804,12 +1804,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "c0eaa380fbc73d8cff077f99cd804e70aff3aeef"
"reference": "3984732cef114a642e6d55df3726ef6439ff8ebd"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/c0eaa380fbc73d8cff077f99cd804e70aff3aeef",
"reference": "c0eaa380fbc73d8cff077f99cd804e70aff3aeef",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/3984732cef114a642e6d55df3726ef6439ff8ebd",
"reference": "3984732cef114a642e6d55df3726ef6439ff8ebd",
"shasum": ""
},
"require": {
@ -1830,7 +1830,7 @@
"tomasvotruba\/class-leak": "^1.2",
"tracy\/tracy": "^2.10"
},
"time": "2025-01-16T02:10:38+00:00",
"time": "2025-01-17T14:48:26+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

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 ceda7a4'), '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 2e0cde6'), '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 c0eaa38'), '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 4661c01'));
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 ceda7a4'), '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 2e0cde6'), '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 3984732'), '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 4661c01'));
private function __construct()
{
}

View File

@ -0,0 +1,87 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\PHPUnit100\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Name;
use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @url https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\PropertyExistsWithoutAssertRector\PropertyExistsWithoutAssertRectorTest
*/
final class PropertyExistsWithoutAssertRector extends AbstractRector
{
/**
* @readonly
*/
private IdentifierManipulator $identifierManipulator;
/**
* @readonly
*/
private TestsNodeAnalyzer $testsNodeAnalyzer;
/**
* @var array<string, string>
*/
private const RENAME_METHODS_WITH_OBJECT_MAP = ['assertClassHasStaticAttribute' => 'assertTrue', 'classHasStaticAttribute' => 'assertTrue', 'assertClassNotHasStaticAttribute' => 'assertFalse'];
public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer)
{
$this->identifierManipulator = $identifierManipulator;
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Replace delited PHPUnit methods: assertClassHasStaticAttribute, classHasStaticAttribute and assertClassNotHasStaticAttribute by property_exists()', [new CodeSample(<<<'CODE_SAMPLE'
$this->assertClassHasStaticAttribute("Class", "property");
$this->classHasStaticAttribute("Class", "property");
$this->assertClassNotHasStaticAttribute("Class", "property");
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$this->assertTrue(property_exists("Class", "property"));
$this->assertTrue(property_exists("Class", "property"));
$this->assertFalse(property_exists("Class", "property"));
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node) : ?Node
{
$map = self::RENAME_METHODS_WITH_OBJECT_MAP;
if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, \array_keys($map))) {
return null;
}
if ($node->isFirstClassCallable() || !isset($node->getArgs()[0], $node->getArgs()[1])) {
return null;
}
$firstNode = new Arg($node->getArgs()[0]->value);
if ($node->getArgs()[1]->value instanceof ClassConstFetch) {
$secondNode = $node->getArgs()[1];
} else {
$secondNode = new Arg($node->getArgs()[1]->value);
}
$funcCall = new FuncCall(new Name('property_exists'), [$secondNode, $firstNode]);
$newArgs = $this->nodeFactory->createArgs([$funcCall]);
unset($node->args[0], $node->args[1]);
$node->args = \array_merge($newArgs, $node->getArgs());
$this->identifierManipulator->renameNodeWithMap($node, $map);
return $node;
}
}

View File

@ -14,7 +14,7 @@ $loader = (static function () {
// Restore the backup and ensure the excluded files are properly marked as loaded
$GLOBALS['__composer_autoload_files'] = \array_merge(
$existingComposerAutoloadFiles,
\array_fill_keys(['0e6d7bf4a5811bfa5cf40c5ccd6fae6a', '5928a00fa978807cf85d90ec3f4b0147'], true)
\array_fill_keys(['5928a00fa978807cf85d90ec3f4b0147', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a'], true)
);
return $loader;