Skip to content

Commit

Permalink
Updated Rector to commit 6b065efef08c34f6e3f69ebd24e24f2418f93007
Browse files Browse the repository at this point in the history
rectorphp/rector-src@6b065ef Bump php-parser to ^4.19.4 (#6338)
  • Loading branch information
TomasVotruba committed Sep 29, 2024
1 parent 2301ae1 commit 3df699e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1811,12 +1811,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "1fdbd38d665a4a2470818fa29d8e5ef7fa76ec49"
"reference": "9fcb7c241b4a64e133f33d5ef37021763fef7dd4"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/1fdbd38d665a4a2470818fa29d8e5ef7fa76ec49",
"reference": "1fdbd38d665a4a2470818fa29d8e5ef7fa76ec49",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/9fcb7c241b4a64e133f33d5ef37021763fef7dd4",
"reference": "9fcb7c241b4a64e133f33d5ef37021763fef7dd4",
"shasum": ""
},
"require": {
Expand All @@ -1840,7 +1840,7 @@
"tomasvotruba\/class-leak": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-09-29T20:46:54+00:00",
"time": "2024-09-29T22:42:55+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
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 1fdbd38'), '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 14fcc87'));
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 9fcb7c2'), '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 14fcc87'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Match_;
use PhpParser\Node\Expr\MethodCall;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function run()
$matcher = $this->exactly(1);
$this->personServiceMock->expects($matcher)
->with([1], $parameters);
->with(1, $parameters);
}
}
CODE_SAMPLE
Expand Down Expand Up @@ -106,8 +107,13 @@ public function refactor(Node $node) : ?\PhpParser\Node\Expr\MethodCall
}
// we look for $this->assertSame(...)
$expectedExpr = $matchAndReturnMatch->getConsecutiveMatchExpr();
if ($expectedExpr instanceof Array_) {
$args = $this->nodeFactory->createArgs($expectedExpr->items);
} else {
$args = [new Arg($expectedExpr)];
}
$node->name = new Identifier('with');
$node->args = [new Arg($expectedExpr)];
$node->args = $args;
// remove the returnCallback if present
if ($matchAndReturnMatch->getWillReturnMatch() instanceof Match_) {
return new MethodCall($node, new Identifier('willReturn'), [new Arg($matchAndReturnMatch->getWillReturnMatchExpr())]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public function refactor(Node $node) : ?\PhpParser\Node\Expr\MethodCall
}
return $this->isNames($node->name, ['equalTo', 'instanceOf']);
});
// replace $this->equalsTo() with direct value
$this->traverseNodesWithCallable($firstArg->value, function (Node $node) : ?Node {
if (!$node instanceof MethodCall) {
return null;
}
if (!$this->isName($node->name, 'equalTo')) {
return null;
}
return $node->getArgs()[0]->value;
});
if ($hasAssertInside && $firstArg->value instanceof Array_) {
$args = $this->nodeFactory->createArgs($firstArg->value->items);
} else {
Expand Down

0 comments on commit 3df699e

Please sign in to comment.