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 @@ -56,7 +56,7 @@
"symplify/phpstan-rules": "^14.12.3",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/fast-unit": "^0.1",
"tomasvotruba/type-coverage": "^2.3",
"tomasvotruba/type-coverage": "^2.3.6",
"tomasvotruba/unused-public": "^2.2",
"tracy/tracy": "^2.12"
},
Expand Down
78 changes: 12 additions & 66 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rules:
parameters:
level: 8

# reportUnmatchedIgnoredErrors: false
reportUnmatchedIgnoredErrors: false
errorFormat: symplify

# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
Expand Down Expand Up @@ -281,10 +281,6 @@ parameters:
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
- rules/Arguments/ArgumentDefaultValueReplacer.php

-
identifier: return.type
message: '#should return non\-empty\-string but returns string#'

# from mapper interface
-
identifier: return.unusedType
Expand All @@ -296,16 +292,6 @@ parameters:
message: '#Method (.*?)refactor\(\) (never returns|should return) (.*?)#'
path: rules/Php70/Rector/If_/IfToSpaceshipRector.php

-
identifier: symplify.forbiddenFuncCall
message: '#Function "var_dump\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php

-
identifier: symplify.forbiddenFuncCall
message: '#Function "class_exists\(\)" cannot be used/left in the code#'
path: src/Configuration/OnlyRuleResolver.php

-
identifier: symplify.forbiddenFuncCall
message: '#Function "property_exists\(\)" cannot be used/left in the code#'
Expand All @@ -323,35 +309,22 @@ parameters:
- src/Validation/RectorConfigValidator.php
- src/Testing/PHPUnit/AbstractLazyTestCase.php
- src/Reporting/DeprecatedRulesReporter.php
- src/Configuration/OnlyRuleResolver.php

# required for reflection
-
identifier: symplify.forbiddenFuncCall
message: '#Function "(.*?)\(\)" cannot be used/left in the code#'
path: src/Util/Reflection/PrivatesAccessor.php

-
identifier: symplify.forbiddenFuncCall
message: '#Function "(function_exists|dump_node)\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php

# chicken/egg
-
identifier: symplify.forbiddenFuncCall
message: '#Function "(d|dd)\(\)" cannot be used/left in the code#'
path: tests/debug_functions.php

# debug functions
# debug and internal functions
-
identifier: symplify.forbiddenFuncCall
message: '#Function "function_exists\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
path: tests/debug_functions.php
paths:
- src/functions/node_helper.php
- tests/debug_functions.php
- src/Util/Reflection/PrivatesAccessor.php

# checks for rector always autoloaded rules only
-
identifier: symplify.forbiddenFuncCall
message: '#Function "(class_exists|interface_exists)\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
path: src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php
paths:
- src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php

# native filesystem calls, required for performance reasons
-
Expand Down Expand Up @@ -408,36 +381,9 @@ parameters:
# fixture Rector rules
-
identifier: symplify.seeAnnotationToTest
path: tests/Issues/

# dev rule
-
identifier: symplify.seeAnnotationToTest
message: '#Class "Rector\\Utils\\Rector\\MoveAbstractRectorToChildrenRector" is missing @see annotation with test case class reference#'

-
identifier: symplify.seeAnnotationToTest
path: tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/Class_

# wider types for external use
-
identifier: typePerfect.narrowPublicClassMethodParamType
message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#'
path: src/Reflection/ClassModifierChecker.php

# false positive - should be fixed
-
identifier: typePerfect.narrowPublicClassMethodParamType
message: '#Parameters should have "PhpParser\\Node\\Expr\\Closure" types as the only types passed to this method#'

-
identifier: typePerfect.narrowPublicClassMethodParamType
message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#'
path: src/VendorLocker/ParentClassMethodTypeOverrideGuard.php

-
identifier: typePerfect.narrowReturnObjectType
message: '#Provide more specific return type "Iterator|PhpParser\\Node" over abstract one#'
paths:
- tests/Issues/
- tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/Class_

-
identifier: typePerfect.noMixedMethodCaller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use Rector\PHPStan\ScopeFetcher;
use Rector\Rector\AbstractRector;
use Rector\Reflection\ClassModifierChecker;
use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver;
Expand Down Expand Up @@ -119,7 +120,13 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
return ! $this->classModifierChecker->isInsideFinalClass($classMethod);
}

return $this->classModifierChecker->isInsideAbstractClass($classMethod) && $classMethod->getStmts() === [];
$scope = ScopeFetcher::fetch($classMethod);
if (! $scope->isInClass()) {
return false;
}

$classReflection = $scope->getClassReflection();
return $classReflection->isAbstract();
}

private function isNotFinalAndHasExceptionOnly(ClassMethod $classMethod): bool
Expand Down
2 changes: 0 additions & 2 deletions src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\BetterPhpDocParser\PhpDoc;

use Override;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Stringable;

Expand All @@ -14,7 +13,6 @@
*/
final class SpacelessPhpDocTagNode extends PhpDocTagNode implements Stringable
{
#[Override]
public function __toString(): string
{
return $this->name . $this->value;
Expand Down
3 changes: 0 additions & 3 deletions src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\BetterPhpDocParser\PhpDocParser;

use Nette\Utils\Strings;
use Override;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
Expand Down Expand Up @@ -111,7 +110,6 @@ public function parseWithNode(BetterTokenIterator $betterTokenIterator, Node $no
return $phpDocNode;
}

#[Override]
public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode
{
// replace generic nodes with DoctrineAnnotations
Expand All @@ -128,7 +126,6 @@ public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode
/**
* @param BetterTokenIterator $tokenIterator
*/
#[Override]
public function parseTagValue(TokenIterator $tokenIterator, string $tag): PhpDocTagValueNode
{
$isPrecededByHorizontalWhitespace = $tokenIterator->isPrecededByHorizontalWhitespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ReflectionProvider;
use Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher;
use Rector\Exception\ShouldNotHappenException;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;

Expand All @@ -20,7 +21,7 @@
final class ClassAnnotationMatcher
{
/**
* @var array<non-empty-string, string>
* @var array<non-empty-string, non-empty-string>
*/
private array $fullyQualifiedNameByHash = [];

Expand All @@ -42,6 +43,9 @@ public function resolveTagFullyQualifiedName(string $tag, Node $node): string
}

$tag = ltrim($tag, '@');
if ($tag === '') {
throw new ShouldNotHappenException();
}

$uses = $this->useImportsResolver->resolve();
$fullyQualifiedClass = $this->resolveFullyQualifiedClass($uses, $node, $tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;

use Override;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use Stringable;
Expand All @@ -20,7 +19,6 @@ public function __construct(
parent::__construct($name, $typeNode, $description);
}

#[Override]
public function __toString(): string
{
// @see https://github.com/rectorphp/rector/issues/3438
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace Rector\BetterPhpDocParser\ValueObject\Type;

use Override;
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
use Stringable;

final class BracketsAwareIntersectionTypeNode extends IntersectionTypeNode implements Stringable
{
#[Override]
public function __toString(): string
{
return implode('&', $this->types);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\BetterPhpDocParser\ValueObject\Type;

use Override;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Stringable;
Expand All @@ -24,7 +23,6 @@ public function __construct(
/**
* Preserve common format
*/
#[Override]
public function __toString(): string
{
$types = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace Rector\BetterPhpDocParser\ValueObject\Type;

use Override;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Stringable;

final class FullyQualifiedIdentifierTypeNode extends IdentifierTypeNode implements Stringable
{
#[Override]
public function __toString(): string
{
return '\\' . ltrim($this->name, '\\');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\BetterPhpDocParser\ValueObject\Type;

use Override;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
Expand All @@ -15,7 +14,6 @@

final class SpacingAwareArrayTypeNode extends ArrayTypeNode implements Stringable
{
#[Override]
public function __toString(): string
{
if ($this->type instanceof CallableTypeNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace Rector\BetterPhpDocParser\ValueObject\Type;

use Override;
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
use Stringable;

final class SpacingAwareCallableTypeNode extends CallableTypeNode implements Stringable
{
#[Override]
public function __toString(): string
{
// keep original (Psalm?) format, see https://github.com/rectorphp/rector/issues/2841
Expand Down
14 changes: 0 additions & 14 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\Configuration\RectorConfigBuilder;
use Rector\Contract\DependencyInjection\RelatedConfigInterface;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Contract\Rector\RectorInterface;
use Rector\Enum\Config\Defaults;
Expand Down Expand Up @@ -294,18 +293,6 @@ public function rule(string $rectorClass): void
// for cache invalidation in case of change
SimpleParameterProvider::addParameter(Option::REGISTERED_RECTOR_RULES, $rectorClass);
}

if (is_a($rectorClass, RelatedConfigInterface::class, true)) {
$configFile = $rectorClass::getConfigFile();

Assert::file($configFile, sprintf(
'The config path "%s" in "%s::getConfigFile()" could not be found',
$configFile,
$rectorClass
));

$this->import($configFile);
}
}

/**
Expand Down Expand Up @@ -565,7 +552,6 @@ public function bound(string $abstract): bool
*
* @param class-string $contract
*/
#[Override]
public function forgetByContract(string $contract): void
{
parent::forgetByContract($contract);
Expand Down
3 changes: 0 additions & 3 deletions src/Console/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\Console;

use Composer\XdebugHandler\XdebugHandler;
use Override;
use Rector\Application\VersionResolver;
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
use Rector\Configuration\Option;
Expand Down Expand Up @@ -41,7 +40,6 @@ public function __construct(
$this->setDefaultCommand('process');
}

#[Override]
public function doRun(InputInterface $input, OutputInterface $output): int
{
// support "-v" as an alias for "--version", as "verbose" option is removed
Expand Down Expand Up @@ -102,7 +100,6 @@ public function doRun(InputInterface $input, OutputInterface $output): int
return parent::doRun($input, $output);
}

#[Override]
protected function getDefaultInputDefinition(): InputDefinition
{
$defaultInputDefinition = parent::getDefaultInputDefinition();
Expand Down
3 changes: 0 additions & 3 deletions src/Console/Style/RectorStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\Console\Style;

use OndraM\CiDetector\CiDetector;
use Override;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -31,7 +30,6 @@ public function __construct(InputInterface $input, OutputInterface $output)
/**
* @see https://github.com/phpstan/phpstan-src/commit/0993d180e5a15a17631d525909356081be59ffeb
*/
#[Override]
public function createProgressBar(int $max = 0): ProgressBar
{
$progressBar = parent::createProgressBar($max);
Expand All @@ -58,7 +56,6 @@ public function createProgressBar(int $max = 0): ProgressBar
return $progressBar;
}

#[Override]
public function progressAdvance(int $step = 1): void
{
// hide progress bar in tests
Expand Down
Loading
Loading