mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 2db6fc62f43a895e8ea3a7d1fa98c03dee299c92
2db6fc62f4
Fix duplicate fixture class take 3 (#3348)
This commit is contained in:
parent
2d77391e5f
commit
8266b2e01e
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '8ddc3d94d4686f10d48c555aae69fe3219360e02';
|
||||
public const PACKAGE_VERSION = '2db6fc62f43a895e8ea3a7d1fa98c03dee299c92';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-02-06 16:01:10';
|
||||
public const RELEASE_DATE = '2023-02-06 16:17:43';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitde8c267da770172dc8da8d9811ac308f::getLoader();
|
||||
return ComposerAutoloaderInit7addbfaa6588a28154c5145cd41a6335::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitde8c267da770172dc8da8d9811ac308f
|
||||
class ComposerAutoloaderInit7addbfaa6588a28154c5145cd41a6335
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitde8c267da770172dc8da8d9811ac308f
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitde8c267da770172dc8da8d9811ac308f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7addbfaa6588a28154c5145cd41a6335', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitde8c267da770172dc8da8d9811ac308f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7addbfaa6588a28154c5145cd41a6335', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitde8c267da770172dc8da8d9811ac308f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit7addbfaa6588a28154c5145cd41a6335::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitde8c267da770172dc8da8d9811ac308f::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit7addbfaa6588a28154c5145cd41a6335::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitde8c267da770172dc8da8d9811ac308f
|
||||
class ComposerStaticInit7addbfaa6588a28154c5145cd41a6335
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3086,9 +3086,9 @@ class ComposerStaticInitde8c267da770172dc8da8d9811ac308f
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitde8c267da770172dc8da8d9811ac308f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitde8c267da770172dc8da8d9811ac308f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitde8c267da770172dc8da8d9811ac308f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7addbfaa6588a28154c5145cd41a6335::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7addbfaa6588a28154c5145cd41a6335::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit7addbfaa6588a28154c5145cd41a6335::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -2059,12 +2059,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "494253872e5efc079cc92036e4e700b0970e1a27"
|
||||
"reference": "008ad4d517f1c62aa7a56124fbe3b59d3c568e5f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/494253872e5efc079cc92036e4e700b0970e1a27",
|
||||
"reference": "494253872e5efc079cc92036e4e700b0970e1a27",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/008ad4d517f1c62aa7a56124fbe3b59d3c568e5f",
|
||||
"reference": "008ad4d517f1c62aa7a56124fbe3b59d3c568e5f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2083,14 +2083,14 @@
|
|||
"rector\/rector-debugging": "dev-main",
|
||||
"rector\/rector-generator": "^0.6.14",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-ci": "^11.2.0.72",
|
||||
"symplify\/easy-coding-standard": "^11.2.7",
|
||||
"symplify\/phpstan-extensions": "^11.1.25",
|
||||
"symplify\/phpstan-rules": "^11.2.3.72",
|
||||
"symplify\/rule-doc-generator": "^11.1.25",
|
||||
"symplify\/vendor-patches": "^11.2.0.72"
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"symplify\/easy-coding-standard": "^11.2",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/phpstan-rules": "^11.2.3",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/vendor-patches": "^11.2.0"
|
||||
},
|
||||
"time": "2023-02-05T09:37:23+00:00",
|
||||
"time": "2023-02-06T16:07:10+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
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-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 ea9cf46'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 46346e2'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9639ef9'), '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 4942538'), '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 cd25b6a'));
|
||||
public const EXTENSIONS = array('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 ea9cf46'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 46346e2'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9639ef9'), '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 008ad4d'), '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 cd25b6a'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
"rector\/rector-src": "dev-main",
|
||||
"phpunit\/phpunit": "^10.0",
|
||||
"phpstan\/phpstan": "^1.9.14",
|
||||
"symplify\/phpstan-rules": "^11.2.3.72",
|
||||
"symplify\/phpstan-extensions": "^11.1.25",
|
||||
"symplify\/easy-coding-standard": "^11.2.7",
|
||||
"symplify\/rule-doc-generator": "^11.1.25",
|
||||
"symplify\/phpstan-rules": "^11.2.3",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/easy-coding-standard": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"rector\/phpstan-rules": "^0.6.5",
|
||||
"phpstan\/extension-installer": "^1.2",
|
||||
"phpstan\/phpstan-strict-rules": "^1.4.5",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2.2",
|
||||
"symplify\/vendor-patches": "^11.2.0.72",
|
||||
"symplify\/easy-ci": "^11.2.0.72",
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"rector\/rector-generator": "^0.6.14",
|
||||
"rector\/rector-debugging": "dev-main"
|
||||
},
|
||||
|
|
|
@ -4,8 +4,8 @@ declare (strict_types=1);
|
|||
namespace Rector\PHPUnit\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\AttributeGroup;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
|
@ -82,48 +82,67 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class, ClassMethod::class];
|
||||
return [Class_::class];
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::ATTRIBUTES;
|
||||
}
|
||||
/**
|
||||
* @param Class_|ClassMethod $node
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
// resolve covers class first
|
||||
$classPhpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
$attributeGroups = [];
|
||||
if ($classPhpDocInfo instanceof PhpDocInfo) {
|
||||
/** @var PhpDocTagNode[] $desiredTagValueNodes */
|
||||
$desiredTagValueNodes = $classPhpDocInfo->getTagsByName('covers');
|
||||
foreach ($desiredTagValueNodes as $desiredTagValueNode) {
|
||||
if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$attributeGroups[] = $this->createAttributeGroup($desiredTagValueNode->value->value);
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($classPhpDocInfo, $desiredTagValueNode);
|
||||
}
|
||||
}
|
||||
$hasChanged = \false;
|
||||
/** @var PhpDocTagNode[] $desiredTagValueNodes */
|
||||
$desiredTagValueNodes = $phpDocInfo->getTagsByName('covers');
|
||||
foreach ($desiredTagValueNodes as $desiredTagValueNode) {
|
||||
if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
|
||||
// resolve covers function
|
||||
foreach ($node->getMethods() as $classMethod) {
|
||||
$classMethodPhpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod);
|
||||
if (!$classMethodPhpDocInfo instanceof PhpDocInfo) {
|
||||
continue;
|
||||
}
|
||||
$annotationValue = $desiredTagValueNode->value->value;
|
||||
if (\strncmp($annotationValue, '::', \strlen('::')) === 0) {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversFunction';
|
||||
$attributeValue = \trim($annotationValue, ':()');
|
||||
} else {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversClass';
|
||||
$attributeValue = \trim($annotationValue) . '::class';
|
||||
/** @var PhpDocTagNode[] $desiredTagValueNodes */
|
||||
$desiredTagValueNodes = $classMethodPhpDocInfo->getTagsByName('covers');
|
||||
foreach ($desiredTagValueNodes as $desiredTagValueNode) {
|
||||
if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$attributeGroups[] = $this->createAttributeGroup($desiredTagValueNode->value->value);
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($classMethodPhpDocInfo, $desiredTagValueNode);
|
||||
}
|
||||
$hasChanged = \true;
|
||||
$attributeGroup = $this->phpAttributeGroupFactory->createFromClassWithItems($attributeClass, [$attributeValue]);
|
||||
$node->attrGroups[] = $attributeGroup;
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $desiredTagValueNode);
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
if ($attributeGroups === []) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
$node->attrGroups = \array_merge($node->attrGroups, $attributeGroups);
|
||||
return $node;
|
||||
}
|
||||
private function createAttributeGroup(string $annotationValue) : AttributeGroup
|
||||
{
|
||||
if (\strncmp($annotationValue, '::', \strlen('::')) === 0) {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversFunction';
|
||||
$attributeValue = \trim($annotationValue, ':()');
|
||||
} else {
|
||||
$attributeClass = 'PHPUnit\\Framework\\Attributes\\CoversClass';
|
||||
$attributeValue = \trim($annotationValue) . '::class';
|
||||
}
|
||||
return $this->phpAttributeGroupFactory->createFromClassWithItems($attributeClass, [$attributeValue]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue