mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 5ac3cb377abf968396c23573d8562e6ab6967f2a
5ac3cb377a
[Php70] Fix Php4 contructor not replaced with __construct() on php 7.4 environment (#5189)
This commit is contained in:
parent
654c818f4e
commit
58494f42d4
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2054,6 +2054,7 @@ return array(
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Class_\\LoadValidatorMetadataToAnnotationRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Class_\\MakeCommandLazyRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/Class_/MakeCommandLazyRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Closure\\StringExtensionToConfigBuilderRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/Closure/StringExtensionToConfigBuilderRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\AssertSameResponseCodeWithDebugContentsRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/AssertSameResponseCodeWithDebugContentsRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\ClassMethod\\AddRouteAnnotationRector' => $vendorDir . '/rector/rector-symfony/rules/Configs/Rector/ClassMethod/AddRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => $vendorDir . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
|
1
vendor/composer/autoload_static.php
vendored
1
vendor/composer/autoload_static.php
vendored
@ -2272,6 +2272,7 @@ class ComposerStaticInit46a0b0ac2ea1371bb06be09a20f71c2b
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Class_\\LoadValidatorMetadataToAnnotationRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Class_\\MakeCommandLazyRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/Class_/MakeCommandLazyRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Closure\\StringExtensionToConfigBuilderRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/Closure/StringExtensionToConfigBuilderRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\AssertSameResponseCodeWithDebugContentsRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/AssertSameResponseCodeWithDebugContentsRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\ClassMethod\\AddRouteAnnotationRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Rector/ClassMethod/AddRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1879,12 +1879,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "873458ca73a73f9becd1680963a347bbcb8e5f43"
|
||||
"reference": "5c5530abf565842c610e18100752932828da8d32"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/873458ca73a73f9becd1680963a347bbcb8e5f43",
|
||||
"reference": "873458ca73a73f9becd1680963a347bbcb8e5f43",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5c5530abf565842c610e18100752932828da8d32",
|
||||
"reference": "5c5530abf565842c610e18100752932828da8d32",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1917,7 +1917,7 @@
|
||||
"tomasvotruba\/unused-public": "^0.2",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-10-05T05:47:32+00:00",
|
||||
"time": "2023-10-19T16:32:06+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/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a846e7f'), '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 3e960af'), '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 7a0a6db'), '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 873458c'));
|
||||
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 a846e7f'), '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 3e960af'), '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 7a0a6db'), '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 5c5530a'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use Rector\Symfony\CodeQuality\Rector\ClassMethod\ActionSuffixRemoverRector;
|
||||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ParamTypeFromRouteRequiredRegexRector;
|
||||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\RemoveUnusedRequestParamRector;
|
||||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector;
|
||||
use Rector\Symfony\CodeQuality\Rector\MethodCall\AssertSameResponseCodeWithDebugContentsRector;
|
||||
use Rector\Symfony\CodeQuality\Rector\MethodCall\LiteralGetToRequestClassConstantRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([
|
||||
@ -25,5 +26,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
ParamTypeFromRouteRequiredRegexRector::class,
|
||||
ActionSuffixRemoverRector::class,
|
||||
LoadValidatorMetadataToAnnotationRector::class,
|
||||
// tests
|
||||
AssertSameResponseCodeWithDebugContentsRector::class,
|
||||
]);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 82 Rules Overview
|
||||
# 83 Rules Overview
|
||||
|
||||
## ActionSuffixRemoverRector
|
||||
|
||||
@ -84,6 +84,30 @@ Replaces ArgumentValueResolverInterface by ValueResolverInterface
|
||||
|
||||
<br>
|
||||
|
||||
## AssertSameResponseCodeWithDebugContentsRector
|
||||
|
||||
Make assertSame(200, `$response->getStatusCode())` in tests comparing response code to include response contents for faster feedback
|
||||
|
||||
- class: [`Rector\Symfony\CodeQuality\Rector\MethodCall\AssertSameResponseCodeWithDebugContentsRector`](../rules/CodeQuality/Rector/MethodCall/AssertSameResponseCodeWithDebugContentsRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SomeClass extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Response $response */
|
||||
$response = $this->processResult();
|
||||
|
||||
- $this->assertSame(200, $response->getStatusCode());
|
||||
+ $this->assertSame(200, $response->getStatusCode(), $response->getContents());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## AuthorizationCheckerIsGrantedExtractorRector
|
||||
|
||||
Change `$this->authorizationChecker->isGranted([$a, $b])` to `$this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b)`
|
||||
|
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\CodeQuality\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\Constant\ConstantIntegerType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Symfony\Tests\CodeQuality\Rector\MethodCall\AssertSameResponseCodeWithDebugContentsRector\AssertSameResponseCodeWithDebugContentsRectorTest
|
||||
*/
|
||||
final class AssertSameResponseCodeWithDebugContentsRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
|
||||
*/
|
||||
private $testsNodeAnalyzer;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer)
|
||||
{
|
||||
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Make assertSame(200, $response->getStatusCode()) in tests comparing response code to include response contents for faster feedback', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SomeClass extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Response $response */
|
||||
$response = $this->processResult();
|
||||
|
||||
$this->assertSame(200, $response->getStatusCode());
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SomeClass extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Response $response */
|
||||
$response = $this->processResult();
|
||||
|
||||
$this->assertSame(200, $response->getStatusCode(), $response->getContents());
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'assertSame')) {
|
||||
return null;
|
||||
}
|
||||
// there cannot be any custom message
|
||||
$args = $node->getArgs();
|
||||
if (\count($args) !== 2) {
|
||||
return null;
|
||||
}
|
||||
$firstArg = $args[0];
|
||||
$comparedValueType = $this->getType($firstArg->value);
|
||||
// must be number
|
||||
if (!$comparedValueType instanceof ConstantIntegerType) {
|
||||
return null;
|
||||
}
|
||||
$responseExpr = $this->matchResponseExpr($args[1]->value);
|
||||
if (!$responseExpr instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
$getContentsMethodCall = new MethodCall($responseExpr, 'getContents');
|
||||
$node->args[2] = new Arg($getContentsMethodCall);
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* We look for $response->getStatusCode()
|
||||
* $client->getResponse()->getStatusCode()
|
||||
*
|
||||
* etc.
|
||||
*/
|
||||
private function matchResponseExpr(Expr $expr) : ?Expr
|
||||
{
|
||||
if (!$expr instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
// must be status method call
|
||||
if (!$this->isName($expr->name, 'getStatusCode')) {
|
||||
return null;
|
||||
}
|
||||
return $expr->var;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user