Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
"phpunit/phpunit": "^13.3",
"rector/swiss-knife": "^2.7",
"shipmonk/composer-dependency-analyser": "^1.8",
"shipmonk/dead-code-detector": "^1.4",
"symfony/process": "^8.1",
"symplify/easy-coding-standard": "^13.2.13",
"symplify/phpstan-rules": "^14.18",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/fast-unit": "^0.1",
"tomasvotruba/type-coverage": "^2.3.6",
"tomasvotruba/unused-public": "^2.2",
"tracy/tracy": "^2.12"
},
"replace": {
Expand Down
21 changes: 16 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,24 @@ parameters:
narrow_param: true
narrow_return: true

# see https://github.com/TomasVotruba/unused-public
unused_public:
methods: true
properties: true
constants: true
# offload breaks cold-cache parallel runs, keep collector data in result cache
shipmonkDeadCode:
cache:
offloadCollectorData: false

ignoreErrors:
# called magically by parent
-
message: '#^Unused Rector\\PhpParser\\Printer\\BetterStandardPrinter\:\:(pInterpolatedStringPart|pStmt_FileNode)$#'
identifier: shipmonk.deadMethod
path: src/PhpParser/Printer/BetterStandardPrinter.php

# deprecated, to be removed
-
message: '#^Unused Rector\\Set\\Contract\\SetInterface\:\:(.*?)$#'
identifier: shipmonk.deadMethod
path: src/Set/Contract/SetInterface.php

# the deprecated set objects are still resolved internally, until every extension bonds its rules
-
message: '#deprecated (class|interface) Rector\\(Set|Bridge)\\#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

interface StrStartWithMatchAndRefactorInterface
{
/**
* @api implemented by child classes
*/
public function match(Identical|NotIdentical|Equal|NotEqual $binaryOp): ?StrStartsWith;

/**
* @api implemented by child classes
* @return FuncCall|BooleanNot|null
*/
public function refactorStrStartsWith(StrStartsWith $strStartsWith): ?Node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

interface PhpDocNodeDecoratorInterface
{
/**
* @api implemented by child classes
*/
public function decorate(PhpDocNode $phpDocNode, Node $phpNode): void;
}
1 change: 1 addition & 0 deletions src/Parallel/Contract/SerializableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
interface SerializableInterface extends JsonSerializable
{
/**
* @api implemented by child classes
* @param array<string, mixed> $json
*/
public static function decode(array $json): self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
use Rector\FileSystem\FilePathHelper;
use Rector\Testing\PHPUnit\AbstractLazyTestCase;

abstract class AbstractPhpDocInfoPrinterTestCase extends AbstractLazyTestCase
{
protected FilePathHelper $filePathHelper;

protected PhpDocInfoPrinter $phpDocInfoPrinter;

private PhpDocInfoFactory $phpDocInfoFactory;
Expand All @@ -24,7 +21,6 @@ protected function setUp(): void
{
parent::setUp();

$this->filePathHelper = $this->make(FilePathHelper::class);
$this->phpDocInfoFactory = $this->make(PhpDocInfoFactory::class);
$this->phpDocInfoPrinter = $this->make(PhpDocInfoPrinter::class);
}
Expand Down
5 changes: 0 additions & 5 deletions tests/Caching/ValueObject/Storage/FileCacheStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,4 @@ public function testSaveLeavesConcurrentReaderOnCompleteFile(): void

$this->fileCacheStorage->clean('aaK1STfY');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config.php';
}
}
13 changes: 8 additions & 5 deletions utils/phpstan/src/Rule/NoScopeFetchBeforeCheapGuardRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
Expand Down Expand Up @@ -102,15 +105,15 @@ private function matchScopeFetchVariableName(Stmt $stmt): ?string
}

$staticCall = $assign->expr;
if (! $staticCall->class instanceof Node\Name) {
if (! $staticCall->class instanceof Name) {
return null;
}

if ($staticCall->class->toString() !== ScopeFetcher::class) {
return null;
}

if (! $staticCall->name instanceof Node\Identifier || $staticCall->name->toString() !== 'fetch') {
if (! $staticCall->name instanceof Identifier || $staticCall->name->toString() !== 'fetch') {
return null;
}

Expand All @@ -128,17 +131,17 @@ private function isReturnNullGuard(If_ $if): bool
return false;
}

return $onlyStmt->expr === null || $this->isNullConstant($onlyStmt->expr);
return ! $onlyStmt->expr instanceof Expr || $this->isNullConstant($onlyStmt->expr);
}

private function isNullConstant(Expr $expr): bool
{
return $expr instanceof Node\Expr\ConstFetch && $expr->name->toLowerString() === 'null';
return $expr instanceof ConstFetch && $expr->name->toLowerString() === 'null';
}

private function usesVariable(Expr $expr, string $variableName): bool
{
$foundVariable = (new NodeFinder())->findFirst(
$foundVariable = new NodeFinder()->findFirst(
[$expr],
static fn (Node $subNode): bool => $subNode instanceof Variable && $subNode->name === $variableName
);
Expand Down
Loading