mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit 1d80ecf67ffb4454579ebd158c7db6e8a016f1ac
1d80ecf67f
Fix first class callable to use combineAcceptors() to avoid assert Arg instance error (#6330)
This commit is contained in:
parent
3bd74e3059
commit
d9b96f4460
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1811,12 +1811,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||||
"reference": "c3a287111f9921e0683ae3ddf2f72a58fe648089"
|
"reference": "a8e2ff178d467a3501fdb69ba60f60a6e5a1988d"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/c3a287111f9921e0683ae3ddf2f72a58fe648089",
|
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/a8e2ff178d467a3501fdb69ba60f60a6e5a1988d",
|
||||||
"reference": "c3a287111f9921e0683ae3ddf2f72a58fe648089",
|
"reference": "a8e2ff178d467a3501fdb69ba60f60a6e5a1988d",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1839,7 +1839,7 @@
|
|||||||
"tomasvotruba\/class-leak": "^0.2",
|
"tomasvotruba\/class-leak": "^0.2",
|
||||||
"tracy\/tracy": "^2.10"
|
"tracy\/tracy": "^2.10"
|
||||||
},
|
},
|
||||||
"time": "2024-09-26T12:39:15+00:00",
|
"time": "2024-09-26T17:10:39+00:00",
|
||||||
"default-branch": true,
|
"default-branch": true,
|
||||||
"type": "rector-extension",
|
"type": "rector-extension",
|
||||||
"extra": {
|
"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
|
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 e75008c'), '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 d9cef57'), '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 c3a2871'), '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 352a84c'));
|
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 e75008c'), '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 d9cef57'), '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 a8e2ff1'), '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 352a84c'));
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use PhpParser\Node\Stmt;
|
|||||||
use PhpParser\Node\Stmt\Expression;
|
use PhpParser\Node\Stmt\Expression;
|
||||||
use PhpParser\Node\Stmt\Return_;
|
use PhpParser\Node\Stmt\Return_;
|
||||||
use PhpParser\Node\Stmt\Throw_;
|
use PhpParser\Node\Stmt\Throw_;
|
||||||
|
use PhpParser\NodeTraverser;
|
||||||
use Rector\Exception\ShouldNotHappenException;
|
use Rector\Exception\ShouldNotHappenException;
|
||||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||||
@ -230,6 +231,19 @@ CODE_SAMPLE
|
|||||||
$node->args = [new Arg(new Variable('matcher'))];
|
$node->args = [new Arg(new Variable('matcher'))];
|
||||||
return $node;
|
return $node;
|
||||||
});
|
});
|
||||||
|
// add expects() method
|
||||||
|
if (!$exactlyCall instanceof Expr) {
|
||||||
|
$this->traverseNodesWithCallable($expression, function (Node $node) : ?int {
|
||||||
|
if (!$node instanceof MethodCall) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($node->var instanceof MethodCall) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$node->var = new MethodCall($node->var, 'expects', [new Arg(new Variable('matcher'))]);
|
||||||
|
return NodeTraverser::STOP_TRAVERSAL;
|
||||||
|
});
|
||||||
|
}
|
||||||
return $exactlyCall;
|
return $exactlyCall;
|
||||||
}
|
}
|
||||||
private function findMethodCall(Expression $expression, string $methodName) : ?MethodCall
|
private function findMethodCall(Expression $expression, string $methodName) : ?MethodCall
|
||||||
@ -266,13 +280,7 @@ CODE_SAMPLE
|
|||||||
{
|
{
|
||||||
$withConsecutiveMethodCall->name = new Identifier('willReturnCallback');
|
$withConsecutiveMethodCall->name = new Identifier('willReturnCallback');
|
||||||
$withConsecutiveMethodCall->args = [new Arg($this->withConsecutiveMatchFactory->createClosure($withConsecutiveMethodCall, $returnStmts, $referenceVariable, $isWithConsecutiveVariadic))];
|
$withConsecutiveMethodCall->args = [new Arg($this->withConsecutiveMatchFactory->createClosure($withConsecutiveMethodCall, $returnStmts, $referenceVariable, $isWithConsecutiveVariadic))];
|
||||||
$hasExpects = $this->findMethodCall($expression, 'expects') instanceof MethodCall;
|
|
||||||
$matcherVariable = new Variable('matcher');
|
$matcherVariable = new Variable('matcher');
|
||||||
if ($hasExpects === \false) {
|
|
||||||
/** @var MethodCall $mockMethodCall */
|
|
||||||
$mockMethodCall = $expression->expr;
|
|
||||||
$mockMethodCall->var = new MethodCall($mockMethodCall->var, 'expects', [new Arg($matcherVariable)]);
|
|
||||||
}
|
|
||||||
$matcherAssign = new Assign($matcherVariable, $expectsCall);
|
$matcherAssign = new Assign($matcherVariable, $expectsCall);
|
||||||
return [new Expression($matcherAssign), $expression];
|
return [new Expression($matcherAssign), $expression];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user