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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"symplify/phpstan-rules": "^14.9.3",
"symplify/vendor-patches": "^11.5",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/unused-public": "^2.1",
"tracy/tracy": "^2.11"
},
"replace": {
Expand Down
22 changes: 21 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ parameters:

# requires exact closure types
checkMissingCallableSignature: true

treatPhpDocTypesAsCertain: false

paths:
Expand Down Expand Up @@ -47,6 +46,12 @@ parameters:
narrow_param: true
narrow_return: true

# see https://github.com/TomasVotruba/unused-public
unused_public:
methods: true
properties: true
constants: true

ignoreErrors:
# required generics on interface array, not helpful
-
Expand Down Expand Up @@ -413,3 +418,18 @@ parameters:
-
identifier: method.parentMethodFinalByPhpDoc
path: rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php

# deprecated
-
identifier: public.method.unused
paths:
- rules/Transform/ValueObject/ClassMethodReference.php
- rules/CodeQuality/ValueObject/KeyAndExpr.php

-
identifier: public.classConstant.unused
paths:
- rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php
- rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php
- rules/Php81/Enum/AttributeName.php

27 changes: 0 additions & 27 deletions rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use PHPStan\Reflection\ReflectionProvider;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\Php81\Enum\AttributeName;
use Rector\PhpAttribute\Enum\DocTagNodeState;

final readonly class PhpAttributeAnalyzer
{
public function __construct(
private NodeNameResolver $nodeNameResolver,
private ReflectionProvider $reflectionProvider,
) {
}

Expand All @@ -42,29 +38,6 @@ public function hasPhpAttribute(Property | ClassLike | ClassMethod | Param $node
return false;
}

/**
* @param AttributeName::* $attributeClass
*/
public function hasInheritedPhpAttribute(Class_ $class, string $attributeClass): bool
{
$className = (string) $this->nodeNameResolver->getName($class);
if (! $this->reflectionProvider->hasClass($className)) {
return false;
}

$classReflection = $this->reflectionProvider->getClass($className);
$ancestorClassReflections = [...$classReflection->getParents(), ...$classReflection->getInterfaces()];

foreach ($ancestorClassReflections as $ancestorClassReflection) {
$nativeReflection = $ancestorClassReflection->getNativeReflection();
if ($nativeReflection->getAttributes($attributeClass) !== []) {
return true;
}
}

return false;
}

/**
* @param string[] $attributeClasses
*/
Expand Down
5 changes: 0 additions & 5 deletions rules/TypeDeclaration/ValueObject/DataProviderNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public function __construct(
Assert::allIsInstanceOf($phpDocTagNodes, PhpDocTagNode::class);
}

public function isEmpty(): bool
{
return $this->getClassMethods() === [];
}

/**
* @return ClassMethod[]
*/
Expand Down
5 changes: 1 addition & 4 deletions src/ChangesReporting/Output/GitHubOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
*/
final readonly class GitHubOutputFormatter implements OutputFormatterInterface
{
/**
* @var string
*/
public const NAME = 'github';
private const NAME = 'github';

private const GROUP_NAME = 'Rector report';

Expand Down
5 changes: 1 addition & 4 deletions src/ChangesReporting/Output/GitlabOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

final readonly class GitlabOutputFormatter implements OutputFormatterInterface
{
/**
* @var string
*/
public const NAME = 'gitlab';
private const NAME = 'gitlab';

private const ERROR_TYPE_ISSUE = 'issue';

Expand Down
2 changes: 1 addition & 1 deletion src/ChangesReporting/Output/JUnitOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

final readonly class JUnitOutputFormatter implements OutputFormatterInterface
{
public const NAME = 'junit';
private const NAME = 'junit';

private const XML_ATTRIBUTE_FILE = 'file';

Expand Down
6 changes: 0 additions & 6 deletions src/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ final class AttributeKey
*/
public const IS_USED_AS_ARG_BY_REF_VALUE = 'is_used_as_arg_by_ref_value';

/**
* @deprecated as never used
* @var string
*/
public const ATTRIBUTE_COMMENT = 'attribute_comment';

/**
* @var string
*/
Expand Down
30 changes: 0 additions & 30 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionReflection;
Expand Down Expand Up @@ -216,34 +214,6 @@ public function resolveFunctionLikeReflectionFromCall(
return null;
}

public function resolveMethodReflectionFromClassMethod(ClassMethod $classMethod, Scope $scope): ?MethodReflection
{
$classReflection = $scope->getClassReflection();
if (! $classReflection instanceof ClassReflection) {
return null;
}

$className = $classReflection->getName();
$methodName = $this->nodeNameResolver->getName($classMethod);

return $this->resolveMethodReflection($className, $methodName, $scope);
}

public function resolveFunctionReflectionFromFunction(Function_ $function): ?FunctionReflection
{
$name = $this->nodeNameResolver->getName($function);
if ($name === null) {
return null;
}

$functionName = new Name($name);
if ($this->reflectionProvider->hasFunction($functionName, null)) {
return $this->reflectionProvider->getFunction($functionName, null);
}

return null;
}

public function resolveMethodReflectionFromNew(New_ $new): ?MethodReflection
{
$newClassType = $this->nodeTypeResolver->getType($new->class);
Expand Down