mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 19:37:55 +01:00
Updated Rector to commit d5f399eee5709932b579d41e3799c3097bbc101f
d5f399eee5
[DeadCode] Remove @return void on return self on RemoveUselessReturnTagRector (#4894)
This commit is contained in:
parent
28c16a1c00
commit
2f2e7aff34
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 ComposerAutoloaderInit08c6becc47ada3067410d3a704631e02::getLoader();
|
||||
return ComposerAutoloaderInit686775e67d4c51227d6f13618b99937c::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1744,6 +1744,7 @@ return array(
|
||||
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\StmtsAwareInterface\\WithConsecutiveRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/StmtsAwareInterface/WithConsecutiveRector.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => $vendorDir . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => $vendorDir . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.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 ComposerAutoloaderInit08c6becc47ada3067410d3a704631e02
|
||||
class ComposerAutoloaderInit686775e67d4c51227d6f13618b99937c
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit08c6becc47ada3067410d3a704631e02
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit08c6becc47ada3067410d3a704631e02', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit686775e67d4c51227d6f13618b99937c', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit08c6becc47ada3067410d3a704631e02', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit686775e67d4c51227d6f13618b99937c', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit08c6becc47ada3067410d3a704631e02::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit686775e67d4c51227d6f13618b99937c::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit08c6becc47ada3067410d3a704631e02::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit686775e67d4c51227d6f13618b99937c::$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 ComposerStaticInit08c6becc47ada3067410d3a704631e02
|
||||
class ComposerStaticInit686775e67d4c51227d6f13618b99937c
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -1964,6 +1964,7 @@ class ComposerStaticInit08c6becc47ada3067410d3a704631e02
|
||||
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\StmtsAwareInterface\\WithConsecutiveRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/StmtsAwareInterface/WithConsecutiveRector.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitLevelSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php',
|
||||
'Rector\\PHPUnit\\Set\\PHPUnitSetList' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Set/PHPUnitSetList.php',
|
||||
'Rector\\PHPUnit\\ValueObject\\AnnotationWithValueToAttribute' => __DIR__ . '/..' . '/rector/rector-phpunit/src/ValueObject/AnnotationWithValueToAttribute.php',
|
||||
@ -2610,9 +2611,9 @@ class ComposerStaticInit08c6becc47ada3067410d3a704631e02
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit08c6becc47ada3067410d3a704631e02::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit08c6becc47ada3067410d3a704631e02::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit08c6becc47ada3067410d3a704631e02::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit686775e67d4c51227d6f13618b99937c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit686775e67d4c51227d6f13618b99937c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit686775e67d4c51227d6f13618b99937c::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
13
vendor/composer/installed.json
vendored
13
vendor/composer/installed.json
vendored
@ -1882,12 +1882,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "e6dd6a009924699ecb60caf0837f423cc13f8511"
|
||||
"reference": "515f9914e89e251edd636bf0635f343841f9b3ea"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/e6dd6a009924699ecb60caf0837f423cc13f8511",
|
||||
"reference": "e6dd6a009924699ecb60caf0837f423cc13f8511",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/515f9914e89e251edd636bf0635f343841f9b3ea",
|
||||
"reference": "515f9914e89e251edd636bf0635f343841f9b3ea",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1913,10 +1913,11 @@
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.2"
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-08-18T12:11:11+00:00",
|
||||
"time": "2023-09-02T19:45:08+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 fabb300'), '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 67928f6'), '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 e6dd6a0'), '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 5c30ddf'));
|
||||
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 fabb300'), '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 67928f6'), '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 515f991'), '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 5c30ddf'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
7
vendor/rector/rector-phpunit/composer.json
vendored
7
vendor/rector/rector-phpunit/composer.json
vendored
@ -21,10 +21,11 @@
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.2",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/class-leak": "^0.1"
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -7,12 +7,13 @@ use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit100\Rector\Class_\AddProphecyTraitRector;
|
||||
use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector;
|
||||
use Rector\PHPUnit\PHPUnit100\Rector\MethodCall\PropertyExistsWithoutAssertRector;
|
||||
use Rector\PHPUnit\Rector\StmtsAwareInterface\WithConsecutiveRector;
|
||||
use Rector\PHPUnit\Set\PHPUnitSetList;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->sets([PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES]);
|
||||
$rectorConfig->rules([StaticDataProviderClassMethodRector::class, PropertyExistsWithoutAssertRector::class, AddProphecyTraitRector::class]);
|
||||
$rectorConfig->rules([StaticDataProviderClassMethodRector::class, PropertyExistsWithoutAssertRector::class, AddProphecyTraitRector::class, WithConsecutiveRector::class]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/4087
|
||||
new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertRegExp', 'assertMatchesRegularExpression'),
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 46 Rules Overview
|
||||
# 47 Rules Overview
|
||||
|
||||
## AddDoesNotPerformAssertionToNonAssertingTestRector
|
||||
|
||||
@ -1022,6 +1022,40 @@ Changes `->with()` to more specific method
|
||||
|
||||
<br>
|
||||
|
||||
## WithConsecutiveRector
|
||||
|
||||
Refactor `"withConsecutive()"` to
|
||||
|
||||
- class: [`Rector\PHPUnit\Rector\StmtsAwareInterface\WithConsecutiveRector`](../src/Rector/StmtsAwareInterface/WithConsecutiveRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
- $this->personServiceMock->expects($this->exactly(2))
|
||||
+ $matcher = $this->exactly(2);
|
||||
+
|
||||
+ $this->personServiceMock->expects($matcher)
|
||||
->method('prepare')
|
||||
- ->withConsecutive(
|
||||
- [1, 2],
|
||||
- [3, 4],
|
||||
- );
|
||||
+ ->willReturnCallback(function () use ($matcher) {
|
||||
+ return match ($matcher->numberOfInvocations()) {
|
||||
+ 1 => [1, 2],
|
||||
+ 2 => [3, 4]
|
||||
+ };
|
||||
+ });
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## YieldDataProviderRector
|
||||
|
||||
Turns array return to yield in data providers
|
||||
|
153
vendor/rector/rector-phpunit/src/Rector/StmtsAwareInterface/WithConsecutiveRector.php
vendored
Normal file
153
vendor/rector/rector-phpunit/src/Rector/StmtsAwareInterface/WithConsecutiveRector.php
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\StmtsAwareInterface;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\ClosureUse;
|
||||
use PhpParser\Node\Expr\Match_;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\MatchArm;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\StmtsAwareInterface\WithConsecutiveRector\WithConsecutiveRectorTest
|
||||
*/
|
||||
final class WithConsecutiveRector 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('Refactor "withConsecutive()" to ', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$this->personServiceMock->expects($this->exactly(2))
|
||||
->method('prepare')
|
||||
->withConsecutive(
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$matcher = $this->exactly(2);
|
||||
|
||||
$this->personServiceMock->expects($matcher)
|
||||
->method('prepare')
|
||||
->willReturnCallback(function () use ($matcher) {
|
||||
return match ($matcher->numberOfInvocations()) {
|
||||
1 => [1, 2],
|
||||
2 => [3, 4]
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Expression::class];
|
||||
}
|
||||
/**
|
||||
* @param Expression $node
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
if (!$node->expr instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
/** @var MethodCall|null $withConsecutiveMethodCall */
|
||||
$withConsecutiveMethodCall = $this->betterNodeFinder->findFirst($node->expr, function (Node $node) : bool {
|
||||
if (!$node instanceof MethodCall) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isName($node->name, 'withConsecutive');
|
||||
});
|
||||
if (!$withConsecutiveMethodCall instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$expectsMethodCall = $this->matchAndRefactorExpectsMethodCall($node);
|
||||
if (!$expectsMethodCall instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
// 2. rename and replace withConsecutive()
|
||||
$withConsecutiveMethodCall->name = new Identifier('willReturnCallback');
|
||||
$withConsecutiveMethodCall->args = [new Arg($this->createClosure($withConsecutiveMethodCall))];
|
||||
$matcherAssign = new Assign(new Variable('matcher'), $expectsMethodCall);
|
||||
return [new Expression($matcherAssign), $node];
|
||||
}
|
||||
private function createClosure(MethodCall $expectsMethodCall) : Closure
|
||||
{
|
||||
$closure = new Closure();
|
||||
$matcherVariable = new Variable('matcher');
|
||||
$closure->uses[] = new ClosureUse($matcherVariable);
|
||||
$match = new Match_(new MethodCall($matcherVariable, new Identifier('numberOfInvocations')));
|
||||
foreach ($expectsMethodCall->getArgs() as $key => $arg) {
|
||||
$match->arms[] = new MatchArm([new LNumber($key + 1)], $arg->value);
|
||||
}
|
||||
$closure->stmts[] = new Return_($match);
|
||||
return $closure;
|
||||
}
|
||||
/**
|
||||
* Replace $this->expects(...)
|
||||
*
|
||||
* @param Expression<MethodCall> $expression
|
||||
*/
|
||||
private function matchAndRefactorExpectsMethodCall(Expression $expression) : ?MethodCall
|
||||
{
|
||||
/** @var MethodCall|null $exactlyMethodCall */
|
||||
$exactlyMethodCall = null;
|
||||
$this->traverseNodesWithCallable($expression, function (Node $node) use(&$exactlyMethodCall) : ?MethodCall {
|
||||
if (!$node instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'expects')) {
|
||||
return null;
|
||||
}
|
||||
$firstArg = $node->getArgs()[0];
|
||||
if (!$firstArg->value instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$exactlyMethodCall = $firstArg->value;
|
||||
$node->args = [new Arg(new Variable('matcher'))];
|
||||
return $node;
|
||||
});
|
||||
return $exactlyMethodCall;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user