Updated Rector to commit 74a7c51d383b8ad5c6adb10cd67fe5f7f8ff290d

74a7c51d38 [automated] Re-Generate Nodes/Rectors Documentation (#5664)
This commit is contained in:
Tomas Votruba 2024-02-25 00:28:09 +00:00
parent b02be823eb
commit 740fedd8a5
15 changed files with 188 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# 361 Rules Overview
# 363 Rules Overview
<br>
@ -54,7 +54,7 @@
- [Strict](#strict) (5)
- [Transform](#transform) (23)
- [Transform](#transform) (24)
- [TypeDeclaration](#typedeclaration) (44)
@ -4693,9 +4693,9 @@ Change annotation to attribute
class SymfonyRoute
{
- /**
- * @Route("/path", name="action")
- * @Route("/path", name="action") api route
- */
+ #[Route(path: '/path', name: 'action')]
+ #[Route(path: '/path', name: 'action')] // api route
public function action()
{
}
@ -5874,6 +5874,21 @@ Replace key value on specific attribute to class constant
<br>
### ConstFetchToClassConstFetchRector
Change const fetch to class const fetch
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\ConstFetch\ConstFetchToClassConstFetchRector`](../rules/Transform/Rector/ConstFetch/ConstFetchToClassConstFetchRector.php)
```diff
-$x = CONTEXT_COURSE
+$x = course::LEVEL
```
<br>
### FuncCallToConstFetchRector
Changes use of function calls to use constants

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'b6f5a0392d90d8f8b7f6fc42db896fdc3562d2d8';
public const PACKAGE_VERSION = '74a7c51d383b8ad5c6adb10cd67fe5f7f8ff290d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-24 08:18:26';
public const RELEASE_DATE = '2024-02-25 00:25:54';
/**
* @var int
*/

View File

@ -1449,6 +1449,7 @@ return array(
'Rector\\DowngradePhp81\\Rector\\StmtsAwareInterface\\DowngradeSetAccessibleReflectionPropertyRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php',
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
'Rector\\EarlyReturn\\NodeFactory\\InvertedIfFactory' => $baseDir . '/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php',

View File

@ -1668,6 +1668,7 @@ class ComposerStaticInit2d887a2f87c676eb32b3e04612865e54
'Rector\\DowngradePhp81\\Rector\\StmtsAwareInterface\\DowngradeSetAccessibleReflectionPropertyRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php',
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
'Rector\\EarlyReturn\\NodeFactory\\InvertedIfFactory' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php',

View File

@ -1742,12 +1742,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "8d1aab27edc3409cd976ddf109ac4933ec33ad5b"
"reference": "68e063523222616f23572af49458eb851405e5b4"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/8d1aab27edc3409cd976ddf109ac4933ec33ad5b",
"reference": "8d1aab27edc3409cd976ddf109ac4933ec33ad5b",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/68e063523222616f23572af49458eb851405e5b4",
"reference": "68e063523222616f23572af49458eb851405e5b4",
"shasum": ""
},
"require": {
@ -1769,7 +1769,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-01-31T21:56:19+00:00",
"time": "2024-02-24T21:31:51+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 803cb22'), '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'));
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 803cb22'), '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 68e0635'), '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

@ -0,0 +1,12 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;
use Rector\DowngradePhp83\Rector\ClassConst\DowngradeTypedClassConstRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->rules([DowngradeTypedClassConstRector::class]);
};

View File

@ -4,7 +4,8 @@ declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeSetList::PHP_82]);
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_82, DowngradeSetList::PHP_82]);
};

View File

@ -0,0 +1,10 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202402;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeSetList::PHP_83]);
};

View File

@ -1,4 +1,4 @@
# 71 Rules Overview
# 74 Rules Overview
## ArrowFunctionToAnonymousFunctionRector
@ -403,6 +403,25 @@ Changes `fread()` or `fwrite()` compare to false to negation check
<br>
## DowngradeHashAlgorithmXxHashRector
Downgrade hash algorithm xxh32, xxh64, xxh3 or xxh128 by default to md5. You can configure the algorithm to downgrade.
- class: [`Rector\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHashRector`](../rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php)
```diff
class SomeClass
{
public function run()
{
- return hash('xxh128', 'some-data-to-hash');
+ return hash('md5', 'some-data-to-hash');
}
}
```
<br>
## DowngradeIsCountableRector
Downgrade `is_countable()` to former version
@ -1144,6 +1163,25 @@ Add `setAccessible()` on ReflectionProperty to allow reading private properties
<br>
## DowngradeStandaloneNullTrueFalseReturnTypeRector
Downgrade standalone return null, true, or false
- class: [`Rector\DowngradePhp82\Rector\FunctionLike\DowngradeStandaloneNullTrueFalseReturnTypeRector`](../rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php)
```diff
final class SomeClass
{
- public function run(): null
+ public function run(): mixed
{
return null;
}
}
```
<br>
## DowngradeStaticTypeDeclarationRector
Remove "static" return and param type, add a `"@param` `$this"` and `"@return` `$this"` tag instead
@ -1386,6 +1424,25 @@ Remove trailing commas in unset
<br>
## DowngradeTypedClassConstRector
Remove typed class constant
- class: [`Rector\DowngradePhp83\Rector\ClassConst\DowngradeTypedClassConstRector`](../rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php)
```diff
final class SomeClass
{
- public string FOO = 'test';
+ /**
+ * @var string
+ */
+ public FOO = 'test';
}
```
<br>
## DowngradeTypedPropertyRector
Changes property type definition from type definitions to `@var` annotations.

View File

@ -0,0 +1,66 @@
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp83\Rector\ClassConst;
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassConst;
use Rector\NodeManipulator\PropertyDecorator;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://wiki.php.net/rfc/typed_class_constants
*
* @see \Rector\Tests\DowngradePhp83\Rector\ClassConst\DowngradeTypedClassConstRector\DowngradeTypedClassConstRectorTest
*/
final class DowngradeTypedClassConstRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\NodeManipulator\PropertyDecorator
*/
private $propertyDecorator;
public function __construct(PropertyDecorator $propertyDecorator)
{
$this->propertyDecorator = $propertyDecorator;
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [ClassConst::class];
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Remove typed class constant', [new CodeSample(<<<'CODE_SAMPLE'
final class SomeClass
{
public string FOO = 'test';
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
final class SomeClass
{
/**
* @var string
*/
public FOO = 'test';
}
CODE_SAMPLE
)]);
}
/**
* @param ClassConst $node
*/
public function refactor(Node $node) : ?Node
{
if (!$node->type instanceof Node) {
return null;
}
$this->propertyDecorator->decorateWithDocBlock($node, $node->type);
$node->type = null;
return $node;
}
}

View File

@ -6,6 +6,7 @@ namespace Rector\NodeManipulator;
use PhpParser\Node\ComplexType;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
@ -35,9 +36,10 @@ final class PropertyDecorator
$this->phpDocTypeChanger = $phpDocTypeChanger;
}
/**
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $property
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode
*/
public function decorateWithDocBlock(Property $property, $typeNode) : void
public function decorateWithDocBlock($property, $typeNode) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
if ($phpDocInfo->getVarTagValueNode() instanceof VarTagValueNode) {

View File

@ -9,6 +9,10 @@ use Rector\Set\Contract\SetListInterface;
*/
final class DowngradeLevelSetList implements SetListInterface
{
/**
* @var string
*/
public const DOWN_TO_PHP_82 = __DIR__ . '/../../../config/set/level/down-to-php82.php';
/**
* @var string
*/

View File

@ -33,4 +33,8 @@ final class DowngradeSetList implements SetListInterface
* @var string
*/
public const PHP_82 = __DIR__ . '/../../../config/set/downgrade-php82.php';
/**
* @var string
*/
public const PHP_83 = __DIR__ . '/../../../config/set/downgrade-php83.php';
}