Skip to content

Commit

Permalink
Updated Rector to commit e7800e9eb89bae4e585f66c26d1f70d83c2a3f4a
Browse files Browse the repository at this point in the history
rectorphp/rector-src@e7800e9 Fix RemoveDoubleAssignRector in case of method call (#6442)
  • Loading branch information
TomasVotruba committed Nov 16, 2024
1 parent ba509eb commit 1de0a37
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 37 deletions.
17 changes: 8 additions & 9 deletions rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@

use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Namespace_;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\DeadCode\SideEffect\SideEffectNodeDetector;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\PHPStan\ScopeFetcher;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand Down Expand Up @@ -55,10 +50,10 @@ public function getRuleDefinition() : RuleDefinition
*/
public function getNodeTypes() : array
{
return [Foreach_::class, FileWithoutNamespace::class, ClassMethod::class, Function_::class, Closure::class, If_::class, Namespace_::class];
return [StmtsAwareInterface::class];
}
/**
* @param Foreach_|FileWithoutNamespace|If_|Namespace_|ClassMethod|Function_|Closure $node
* @param StmtsAwareInterface $node
*/
public function refactor(Node $node) : ?Node
{
Expand Down Expand Up @@ -98,6 +93,10 @@ public function refactor(Node $node) : ?Node
if ($this->sideEffectNodeDetector->detectCallExpr($stmt->expr->expr, $scope)) {
continue;
}
// next stmts can have side effect as well
if ($nextAssign->expr instanceof MethodCall) {
continue;
}
if (!$stmt->expr->var instanceof Variable && !$stmt->expr->var instanceof PropertyFetch && !$stmt->expr->var instanceof StaticPropertyFetch) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '9cd63761b6016294caf2e9f412c4ff46edefa7f1';
public const PACKAGE_VERSION = 'e7800e9eb89bae4e585f66c26d1f70d83c2a3f4a';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-11-15 12:57:55';
public const RELEASE_DATE = '2024-11-16 12:46:48';
/**
* @var int
*/
Expand Down
32 changes: 16 additions & 16 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,17 @@
},
{
"name": "illuminate\/container",
"version": "v11.31.0",
"version_normalized": "11.31.0.0",
"version": "v11.32.0",
"version_normalized": "11.32.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git",
"reference": "06dfc614aff58384b28ba5ad191f6a02d6b192cb"
"reference": "6e31eb49e9c9e68356a55cd8f18fb8830b8158cd"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/illuminate\/container\/zipball\/06dfc614aff58384b28ba5ad191f6a02d6b192cb",
"reference": "06dfc614aff58384b28ba5ad191f6a02d6b192cb",
"url": "https:\/\/api.github.com\/repos\/illuminate\/container\/zipball\/6e31eb49e9c9e68356a55cd8f18fb8830b8158cd",
"reference": "6e31eb49e9c9e68356a55cd8f18fb8830b8158cd",
"shasum": ""
},
"require": {
Expand All @@ -533,7 +533,7 @@
"provide": {
"psr\/container-implementation": "1.1|2.0"
},
"time": "2024-10-11T15:30:11+00:00",
"time": "2024-11-14T15:31:35+00:00",
"type": "library",
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -569,25 +569,25 @@
},
{
"name": "illuminate\/contracts",
"version": "v11.31.0",
"version_normalized": "11.31.0.0",
"version": "v11.32.0",
"version_normalized": "11.32.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git",
"reference": "56312862af937bd6da8e6dc8bbd88188dfb478f8"
"reference": "44c15aec6ea0d997e0885aa5b04876fe8a141433"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/56312862af937bd6da8e6dc8bbd88188dfb478f8",
"reference": "56312862af937bd6da8e6dc8bbd88188dfb478f8",
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/44c15aec6ea0d997e0885aa5b04876fe8a141433",
"reference": "44c15aec6ea0d997e0885aa5b04876fe8a141433",
"shasum": ""
},
"require": {
"php": "^8.2",
"psr\/container": "^1.1.1|^2.0.1",
"psr\/simple-cache": "^1.0|^2.0|^3.0"
},
"time": "2024-09-22T15:08:08+00:00",
"time": "2024-11-15T15:40:33+00:00",
"type": "library",
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -1811,12 +1811,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "464dec2f831645a49dc3be86be76d2bfcaca8e74"
"reference": "d9914061c9512861b8e61a1df1b1e55aed1b915f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/464dec2f831645a49dc3be86be76d2bfcaca8e74",
"reference": "464dec2f831645a49dc3be86be76d2bfcaca8e74",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/d9914061c9512861b8e61a1df1b1e55aed1b915f",
"reference": "d9914061c9512861b8e61a1df1b1e55aed1b915f",
"shasum": ""
},
"require": {
Expand All @@ -1840,7 +1840,7 @@
"tomasvotruba\/class-leak": "^1.1.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-11-13T15:11:17+00:00",
"time": "2024-11-16T11:18:37+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.

4 changes: 3 additions & 1 deletion vendor/illuminate/container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ protected function resolve($abstract, $parameters = [], $raiseEvents = \true)
// Before returning, we will also set the resolved flag to "true" and pop off
// the parameter overrides for this build. After those two things are done
// we will be ready to return back the fully constructed class instance.
$this->resolved[$abstract] = \true;
if (!$needsContextualBuild) {
$this->resolved[$abstract] = \true;
}
\array_pop($this->with);
return $object;
}
Expand Down
7 changes: 6 additions & 1 deletion vendor/illuminate/contracts/Pagination/CursorPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace RectorPrefix202411\Illuminate\Contracts\Pagination;

/**
* @template TKey of array-key
*
* @template-covariant TValue
*/
interface CursorPaginator
{
/**
Expand Down Expand Up @@ -47,7 +52,7 @@ public function nextPageUrl();
/**
* Get all of the items being paginated.
*
* @return array
* @return array<TKey, TValue>
*/
public function items();
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

namespace RectorPrefix202411\Illuminate\Contracts\Pagination;

/**
* @template TKey of array-key
*
* @template-covariant TValue
*
* @extends Paginator<TKey, TValue>
*/
interface LengthAwarePaginator extends Paginator
{
/**
Expand Down
7 changes: 6 additions & 1 deletion vendor/illuminate/contracts/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace RectorPrefix202411\Illuminate\Contracts\Pagination;

/**
* @template TKey of array-key
*
* @template-covariant TValue
*/
interface Paginator
{
/**
Expand Down Expand Up @@ -41,7 +46,7 @@ public function previousPageUrl();
/**
* Get all of the items being paginated.
*
* @return array
* @return array<TKey, TValue>
*/
public function items();
/**
Expand Down
2 changes: 1 addition & 1 deletion vendor/illuminate/contracts/Routing/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function redirectTo($path, $status = 302, $headers = [], $secure = null);
/**
* Create a new redirect response to a named route.
*
* @param string $route
* @param \BackedEnum|string $route
* @param mixed $parameters
* @param int $status
* @param array $headers
Expand Down
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 9cfbe48'), '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 eb03bfe'), '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 464dec2'), '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 d0f8cf2'));
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 9cfbe48'), '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 eb03bfe'), '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 d991406'), '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 d0f8cf2'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ public function getRuleDefinition() : RuleDefinition
// code before
<<<'CODE_SAMPLE'
$this->assertSame(10.20, $value);
$this->assertEquals(10.20, $value);
$this->assertEquals(10.200, $value);
$this->assertSame(10, $value);
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
$this->assertEqualsWithDelta(10.20, $value, PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(10.20, $value, PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(10.200, $value, PHP_FLOAT_EPSILON);
$this->assertSame(10, $value);
CODE_SAMPLE

)]);
Expand Down Expand Up @@ -79,10 +75,14 @@ public function refactor(Node $node) : ?Node
if (!$firstValue instanceof DNumber) {
return null;
}
$customMessageArg = $args[2] ?? null;
$newMethodCall = $this->assertCallFactory->createCallWithName($node, 'assertEqualsWithDelta');
$newMethodCall->args[0] = $args[0];
$newMethodCall->args[1] = $args[1];
$newMethodCall->args[2] = new Arg(new ConstFetch(new Name('PHP_FLOAT_EPSILON')));
if ($customMessageArg instanceof Arg) {
$newMethodCall->args[] = $customMessageArg;
}
return $newMethodCall;
}
public function provideMinPhpVersion() : int
Expand Down

0 comments on commit 1de0a37

Please sign in to comment.