Skip to content

Commit

Permalink
[PHPStan] Clean up ignore errors (#5634)
Browse files Browse the repository at this point in the history
* [PHPStan] Clean up ignore errors

* [PHPStan] Clean up ignore errors

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Feb 18, 2024
1 parent a8d0dbe commit 287deb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
3 changes: 0 additions & 3 deletions phpstan.neon
Expand Up @@ -316,9 +316,6 @@ parameters:
message: '#Function "dump_node\(\)" cannot be used/left in the code\: #'
path: src/functions/node_helper.php

# phpstan 1.10.0
- '#Parameter 3 should use "PHPStan\\Reflection\\ParameterReflectionWithPhpDocs" type as the only type passed to this method#'

# false positive on enums
- '#Method Rector\\Console\\Command\\SetupCICommand\:\:resolveCurrentCI\(\) never returns (.*?) so it can be removed from the return type#'

Expand Down
@@ -1,7 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Transform\Rector\ConstFetch;

use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;
Expand Down Expand Up @@ -31,20 +35,22 @@ public function getRuleDefinition(): RuleDefinition

public function getNodeTypes(): array
{
return [Node\Expr\ConstFetch::class];
return [ConstFetch::class];
}

public function refactor(Node $node)
public function refactor(Node $node): ?ClassConstFetch
{
foreach ($this->constFetchToClassConsts as $constFetchToClassConst) {
if (! $this->isName($node, $constFetchToClassConst->getOldConstName())) {
continue;
}

return $this->nodeFactory->createClassConstFetch(
$constFetchToClassConst->getNewClassName(),
$constFetchToClassConst->getNewConstName()
);
}

return null;
}

Expand Down
19 changes: 5 additions & 14 deletions rules/Transform/ValueObject/ConstFetchToClassConstFetch.php
Expand Up @@ -6,22 +6,13 @@

use Rector\Validation\RectorAssert;

final class ConstFetchToClassConstFetch
final readonly class ConstFetchToClassConstFetch
{
private string $oldConstName;

private string $newClassName;

private string $newConstName;

public function __construct(string $oldConstName, string $newClassName, string $newConstName)
public function __construct(private string $oldConstName, private string $newClassName, private string $newConstName)
{
$this->oldConstName = $oldConstName;
$this->newClassName = $newClassName;
$this->newConstName = $newConstName;
RectorAssert::constantName($oldConstName);
RectorAssert::className($newClassName);
RectorAssert::constantName($newConstName);
RectorAssert::constantName($this->oldConstName);
RectorAssert::className($this->newClassName);
RectorAssert::constantName($this->newConstName);
}

public function getOldConstName(): string
Expand Down

0 comments on commit 287deb2

Please sign in to comment.