mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
Updated Rector to commit c01925aad05a9baf0a44701a069a989ca3c0edc8
c01925aad0
Resolve native return-type from native union-type in short ternary (#4606)
This commit is contained in:
parent
abd2958b1c
commit
e8f8e6a94d
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInite0b3f28bb44c98e5afb2da9d4deed44a::getLoader();
|
||||
return ComposerAutoloaderInit8f22c058fe3b976c909bb1a233c9c18e::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2062,6 +2062,7 @@ return array(
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\TestWithAnnotationToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\TicketAnnotationToAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddSeeTestAnnotationRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddSeeTestAnnotationRector.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInite0b3f28bb44c98e5afb2da9d4deed44a
|
||||
class ComposerAutoloaderInit8f22c058fe3b976c909bb1a233c9c18e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInite0b3f28bb44c98e5afb2da9d4deed44a
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite0b3f28bb44c98e5afb2da9d4deed44a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit8f22c058fe3b976c909bb1a233c9c18e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite0b3f28bb44c98e5afb2da9d4deed44a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit8f22c058fe3b976c909bb1a233c9c18e', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a
|
||||
class ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2316,6 +2316,7 @@ class ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\ClassMethod\\TestWithAnnotationToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\AnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\CoversAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/CoversAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\AnnotationsToAttributes\\Rector\\Class_\\TicketAnnotationToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
|
||||
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddSeeTestAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddSeeTestAnnotationRector.php',
|
||||
@ -3022,9 +3023,9 @@ class ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite0b3f28bb44c98e5afb2da9d4deed44a::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit8f22c058fe3b976c909bb1a233c9c18e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -2054,12 +2054,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "87b593f613eacbb0d3b3113c9ac47ac369b57d98"
|
||||
"reference": "04381624cfee50410f0fd06f4cedd21fbd883535"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/87b593f613eacbb0d3b3113c9ac47ac369b57d98",
|
||||
"reference": "87b593f613eacbb0d3b3113c9ac47ac369b57d98",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/04381624cfee50410f0fd06f4cedd21fbd883535",
|
||||
"reference": "04381624cfee50410f0fd06f4cedd21fbd883535",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2088,7 +2088,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-07-20T14:02:47+00:00",
|
||||
"time": "2023-07-26T13:18:46+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-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 1c50ebb'), '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 89173a2'), '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 87b593f'), '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 a0af12a'));
|
||||
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 1c50ebb'), '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 89173a2'), '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 0438162'), '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 a0af12a'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -8,12 +8,14 @@ use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\TicketAnnotationToAttributeRector;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\TestWithAnnotationToAttributeRector;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([
|
||||
TicketAnnotationToAttributeRector::class,
|
||||
TestWithAnnotationToAttributeRector::class,
|
||||
DataProviderAnnotationToAttributeRector::class,
|
||||
CoversAnnotationWithValueToAttributeRector::class,
|
||||
@ -29,7 +31,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
*/
|
||||
DependsAnnotationWithValueToAttributeRector::class,
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\\Framework\\Attributes\\BackupGlobals', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('backupStaticAttributes', 'PHPUnit\\Framework\\Attributes\\BackupStaticProperties', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('preserveGlobalState', 'PHPUnit\\Framework\\Attributes\\PreserveGlobalState', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('depends', 'PHPUnit\\Framework\\Attributes\\Depends'), new AnnotationWithValueToAttribute('group', 'PHPUnit\\Framework\\Attributes\\Group'), new AnnotationWithValueToAttribute('ticket', 'PHPUnit\\Framework\\Attributes\\Ticket'), new AnnotationWithValueToAttribute('uses', 'PHPUnit\\Framework\\Attributes\\UsesClass'), new AnnotationWithValueToAttribute('testDox', 'PHPUnit\\Framework\\Attributes\\TestDox'), new AnnotationWithValueToAttribute('testdox', 'PHPUnit\\Framework\\Attributes\\TestDox')]);
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\\Framework\\Attributes\\BackupGlobals', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('backupStaticAttributes', 'PHPUnit\\Framework\\Attributes\\BackupStaticProperties', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('preserveGlobalState', 'PHPUnit\\Framework\\Attributes\\PreserveGlobalState', ['enabled' => \true, 'disabled' => \false]), new AnnotationWithValueToAttribute('depends', 'PHPUnit\\Framework\\Attributes\\Depends'), new AnnotationWithValueToAttribute('group', 'PHPUnit\\Framework\\Attributes\\Group'), new AnnotationWithValueToAttribute('uses', 'PHPUnit\\Framework\\Attributes\\UsesClass'), new AnnotationWithValueToAttribute('testDox', 'PHPUnit\\Framework\\Attributes\\TestDox'), new AnnotationWithValueToAttribute('testdox', 'PHPUnit\\Framework\\Attributes\\TestDox')]);
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
|
||||
// @see https://github.com/sebastianbergmann/phpunit/issues/4502
|
||||
new AnnotationToAttribute('after', 'PHPUnit\\Framework\\Attributes\\After'),
|
||||
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\AttributeGroup;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\Ticket;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://docs.phpunit.de/en/10.0/annotations.html#ticket
|
||||
*
|
||||
* @see \Rector\PHPUnit\Tests\AnnotationsToAttributes\Rector\Class_\TicketAnnotationToAttributeRector\TicketAnnotationToAttributeRectorTest
|
||||
*/
|
||||
final class TicketAnnotationToAttributeRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover
|
||||
*/
|
||||
private $phpDocTagRemover;
|
||||
public function __construct(PhpDocTagRemover $phpDocTagRemover)
|
||||
{
|
||||
$this->phpDocTagRemover = $phpDocTagRemover;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change annotations with value to attribute', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @ticket 123
|
||||
*/
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Ticket;
|
||||
|
||||
#[Ticket('123')]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Class_::class, ClassMethod::class];
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::ATTRIBUTES;
|
||||
}
|
||||
/**
|
||||
* @param Class_|ClassMethod $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
}
|
||||
/** @var PhpDocTagNode[] $ticketTagValueNodes */
|
||||
$ticketTagValueNodes = $phpDocInfo->getTagsByName('ticket');
|
||||
if ($ticketTagValueNodes === []) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach ($ticketTagValueNodes as $ticketTagValueNode) {
|
||||
if (!$ticketTagValueNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$stringValue = $ticketTagValueNode->value->value;
|
||||
$attribute = $this->createTicketAttribute($stringValue);
|
||||
$node->attrGroups[] = new AttributeGroup([$attribute]);
|
||||
// cleanup
|
||||
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $ticketTagValueNode);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function createTicketAttribute(string $stringValue) : Attribute
|
||||
{
|
||||
$fullyQualified = new FullyQualified(Ticket::class);
|
||||
$ticketString = new String_($stringValue);
|
||||
$args = [new Arg($ticketString)];
|
||||
return new Attribute($fullyQualified, $args);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user