Skip to content

Commit

Permalink
Remove PARENT_NODE from RemoveUnusedVariableAssignRector (#3935)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 23, 2023
1 parent 8f3569e commit d603b00
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 507 deletions.
12 changes: 5 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,6 @@ parameters:
message: '#The path "/\.\./\.\./stubs\-rector" was not found#'
path: src/Autoloading/BootstrapFilesIncluder.php # 54

-
message: '#PHPDoc tag @param for parameter \$node with type array<PhpParser\\Node\\Stmt\\Expression>\|null is incompatible with native type PhpParser\\Node#'
paths:
- rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php

-
message: '#Access to an undefined property PhpParser\\Node\:\:\$expr#'
paths:
Expand Down Expand Up @@ -743,8 +738,8 @@ parameters:
path: src/Kernel/RectorKernel.php

# expression generics
- '#PHPDoc tag @return contains generic type PhpParser\\Node\\Stmt\\Expression<PhpParser\\Node\\Expr\\Assign> but class PhpParser\\Node\\Stmt\\Expression is not generic#'
- '#PHPDoc tag @var for variable \$previousStmt contains generic type PhpParser\\Node\\Stmt\\Expression<PhpParser\\Node\\Expr\\Assign\|PhpParser\\Node\\Expr\\AssignOp> but class PhpParser\\Node\\Stmt\\Expression is not generic#'
- '#PhpParser\\Node\\Stmt\\Expression is not generic#'

- '#Parameter \#3 \$assign of method Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector\:\:processSimplifyUselessVariable\(\) expects PhpParser\\Node\\Expr\\Assign\|PhpParser\\Node\\Expr\\AssignOp, PhpParser\\Node\\Expr given#'

- '#Anonymous variable in a (.*?)->stmts\[(.*?)]\->\.\.\.\(\)` method call can lead to false dead methods\. Make sure the variable type is known#'
Expand All @@ -754,3 +749,6 @@ parameters:
# WIP
- '#Fetching deprecated class constant PARENT_NODE#'
- '#Return type \(int\|PhpParser\\Node\\Expr\\FuncCall\|PhpParser\\Node\\Expr\\Ternary\|null\) of method Rector\\Php71\\Rector\\FuncCall\\CountOnNullRector\:\:refactorWithScope\(\) should be covariant with return type \(1\|2\|3\|4\|array<PhpParser\\Node>\|PhpParser\\Node\|null\) of method Rector\\Core\\Contract\\Rector\\ScopeAwarePhpRectorInterface\:\:refactorWithScope\(\)#'

# resolve before 1.0
- '#Call to deprecated method resolveNextNode\(\) of class Rector\\Core\\PhpParser\\Node\\BetterNodeFinder\:#'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

class ShadowedLocalVariable {
final class SkipShadowedLocalVariable
{
public function run(array $params)
{
$toDate = null;
Expand All @@ -17,24 +18,3 @@ class ShadowedLocalVariable {
}
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

class ShadowedLocalVariable {
public function run(array $params)
{
if (isset($params['todate'])) {
$toDate = \DateTime::createFromFormat('d.m.Y', $params['todate']);
} else {
$toDate = new \DateTime();
$toDate->setTimestamp(strtotime('now - 3 month'));
}

return $toDate;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

class SkipNextIncludeAnotherFile
final class SkipNextIncludeAnotherFile
{
public function run()
{
Expand All @@ -11,17 +11,5 @@ class SkipNextIncludeAnotherFile
if (rand(0, 1)) {
include 'test.php';
}

if (rand(0, 1)) {
include_once 'test.php';
}

if (rand(0, 1)) {
require 'test.php';
}

if (rand(0, 1)) {
require_once 'test.php';
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

use Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Source\HeavyClass;
use RuntimeException;

final class SkipTryCatchOnNewInstance
{
public function run()
{
try {
$obj = new HeavyClass();
} catch (RuntimeException $r) {
throw $r;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

final class SkipVariableName
{
public function run($abcdef = 'foo')
{
$$abcdef = 'test';
}
}

This file was deleted.

Loading

0 comments on commit d603b00

Please sign in to comment.