mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
185ee1b473
commit
21c4a84cd6
|
@ -3684,8 +3684,8 @@ Remove unused parameter in required autowire method
|
|||
private $visibilityManipulator;
|
||||
|
||||
#[Required]
|
||||
- public function autowireSomeService(VisibilityManipulator $visibilityManipulator)
|
||||
+ public function autowireSomeService()
|
||||
- public function autowire(VisibilityManipulator $visibilityManipulator)
|
||||
+ public function autowire()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ final class PhpDocClassRenamer
|
|||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
$className = $doctrineAnnotationTagValueNode->getSilentValue();
|
||||
|
||||
if ($className) {
|
||||
if (is_string($className)) {
|
||||
if ($className === $oldClass) {
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
||||
continue;
|
||||
|
|
|
@ -133,7 +133,7 @@ final class PhpDocTypeChanger
|
|||
public function copyPropertyDocToParam(Property $property, Param $param): void
|
||||
{
|
||||
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
if (! $phpDocInfo) {
|
||||
if (! $phpDocInfo instanceof PhpDocInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ final class PlainValueParser
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowirePlainValueParser(
|
||||
public function autowire(
|
||||
StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser,
|
||||
ArrayParser $arrayParser
|
||||
): void {
|
||||
|
|
|
@ -169,7 +169,7 @@ final class PhpDocInfoPrinter
|
|||
$output = $this->printEnd($output);
|
||||
|
||||
// fix missing start
|
||||
if (! StringUtils::isMatch($output, self::DOCBLOCK_START_REGEX) && $output) {
|
||||
if (! StringUtils::isMatch($output, self::DOCBLOCK_START_REGEX) && $output !== '') {
|
||||
$output = '/**' . $output;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ final class ConsoleOutputFormatter implements OutputFormatterInterface
|
|||
if ($fileDiff->getRectorChanges() !== []) {
|
||||
$this->outputStyle->writeln('<options=underscore>Applied rules:</>');
|
||||
$this->outputStyle->listing($rectorsChangelogsLines);
|
||||
$this->outputStyle->newLine();
|
||||
$this->outputStyle->newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,12 +107,12 @@ final class ConsoleOutputFormatter implements OutputFormatterInterface
|
|||
$message = sprintf(
|
||||
'Could not process "%s" file%s, due to: %s"%s".',
|
||||
$error->getRelativeFilePath(),
|
||||
$error->getRectorClass() ? ' by "' . $error->getRectorClass() . '"' : '',
|
||||
$error->getRectorClass() !== null ? ' by "' . $error->getRectorClass() . '"' : '',
|
||||
PHP_EOL,
|
||||
$errorMessage
|
||||
);
|
||||
|
||||
if ($error->getLine()) {
|
||||
if ($error->getLine() !== null) {
|
||||
$message .= ' On line: ' . $error->getLine();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ final class XmlFileFormatter implements FileFormatterInterface
|
|||
*/
|
||||
private const IS_CLOSING_TAG_REGEX = '#^\s*<\/#';
|
||||
|
||||
private ?int $depth = null;
|
||||
private int $depth = 0;
|
||||
|
||||
private int $indent = 4;
|
||||
|
||||
|
@ -79,7 +79,7 @@ final class XmlFileFormatter implements FileFormatterInterface
|
|||
$parts = $this->getXmlParts($xml);
|
||||
|
||||
if (str_starts_with($parts[0], '<?xml')) {
|
||||
$output = array_shift($parts) . $editorConfigConfiguration->getNewline();
|
||||
$output = array_shift($parts) . $editorConfigConfiguration->getNewLine();
|
||||
}
|
||||
|
||||
foreach ($parts as $part) {
|
||||
|
@ -104,10 +104,10 @@ final class XmlFileFormatter implements FileFormatterInterface
|
|||
$this->runPre($part);
|
||||
|
||||
if ($this->preserveWhitespace) {
|
||||
$output .= $part . $editorConfigConfiguration->getNewline();
|
||||
$output .= $part . $editorConfigConfiguration->getNewLine();
|
||||
} else {
|
||||
$part = trim($part);
|
||||
$output .= $this->getPaddedString($part) . $editorConfigConfiguration->getNewline();
|
||||
$output .= $this->getPaddedString($part) . $editorConfigConfiguration->getNewLine();
|
||||
}
|
||||
|
||||
$this->runPost($part);
|
||||
|
|
|
@ -11,7 +11,7 @@ use Rector\FileSystemRector\Contract\FileWithNodesInterface;
|
|||
final class AddedFileWithNodes implements AddedFileInterface, FileWithNodesInterface
|
||||
{
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
* @param Node\Stmt[] $nodes
|
||||
*/
|
||||
public function __construct(
|
||||
private string $filePath,
|
||||
|
@ -25,7 +25,7 @@ final class AddedFileWithNodes implements AddedFileInterface, FileWithNodesInter
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Node[]
|
||||
* @return Node\Stmt[]
|
||||
*/
|
||||
public function getNodes(): array
|
||||
{
|
||||
|
|
|
@ -6,12 +6,18 @@ namespace Rector\NodeNameResolver\Contract;
|
|||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @template TNode as Node
|
||||
*/
|
||||
interface NodeNameResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
* @return class-string<TNode>
|
||||
*/
|
||||
public function getNode(): string;
|
||||
|
||||
/**
|
||||
* @param TNode $node
|
||||
*/
|
||||
public function resolve(Node $node): ?string;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ final class InvalidNameNodeReporter
|
|||
$backtrace = debug_backtrace();
|
||||
$rectorBacktrace = $this->matchRectorBacktraceCall($backtrace);
|
||||
|
||||
if ($rectorBacktrace) {
|
||||
if ($rectorBacktrace !== null) {
|
||||
// issues to find the file in prefixed
|
||||
if (file_exists($rectorBacktrace[self::FILE])) {
|
||||
$smartFileInfo = new SmartFileInfo($rectorBacktrace[self::FILE]);
|
||||
|
|
|
@ -10,19 +10,19 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<ClassConstFetch>
|
||||
*/
|
||||
final class ClassConstFetchNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireClassConstFetchNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return ClassConstFetch::class;
|
||||
|
|
|
@ -10,19 +10,19 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<ClassConst>
|
||||
*/
|
||||
final class ClassConstNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireClassConstNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return ClassConst::class;
|
||||
|
|
|
@ -5,32 +5,31 @@ declare(strict_types=1);
|
|||
namespace Rector\NodeNameResolver\NodeNameResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<ClassLike>
|
||||
*/
|
||||
final class ClassNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireClassNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return ClassLike::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Class_ $node
|
||||
* @param ClassLike $node
|
||||
*/
|
||||
public function resolve(Node $node): ?string
|
||||
{
|
||||
|
|
|
@ -8,11 +8,11 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Expr\Empty_;
|
||||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Empty_>
|
||||
*/
|
||||
final class EmptyNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Empty_::class;
|
||||
|
|
|
@ -12,6 +12,9 @@ use PHPStan\Reflection\ReflectionProvider;
|
|||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<FuncCall>
|
||||
*/
|
||||
final class FuncCallNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -19,9 +22,6 @@ final class FuncCallNameResolver implements NodeNameResolverInterface
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return FuncCall::class;
|
||||
|
|
|
@ -10,11 +10,11 @@ use PHPStan\Analyser\Scope;
|
|||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Function_>
|
||||
*/
|
||||
final class FunctionNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Function_::class;
|
||||
|
@ -33,7 +33,7 @@ final class FunctionNameResolver implements NodeNameResolverInterface
|
|||
}
|
||||
|
||||
$namespaceName = $scope->getNamespace();
|
||||
if ($namespaceName) {
|
||||
if ($namespaceName !== null) {
|
||||
return $namespaceName . '\\' . $bareName;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ use PhpParser\Node\Name\FullyQualified;
|
|||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Name>
|
||||
*/
|
||||
final class NameNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -18,9 +21,6 @@ final class NameNameResolver implements NodeNameResolverInterface
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Name::class;
|
||||
|
|
|
@ -10,19 +10,19 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Param>
|
||||
*/
|
||||
final class ParamNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireParamNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Param::class;
|
||||
|
|
|
@ -10,19 +10,19 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Property>
|
||||
*/
|
||||
final class PropertyNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowirePropertyNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Property::class;
|
||||
|
|
|
@ -10,19 +10,19 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Use_>
|
||||
*/
|
||||
final class UseNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
private NodeNameResolver $nodeNameResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireUseNameResolver(NodeNameResolver $nodeNameResolver): void
|
||||
public function autowire(NodeNameResolver $nodeNameResolver): void
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Use_::class;
|
||||
|
|
|
@ -11,11 +11,11 @@ use PhpParser\Node\Expr\Variable;
|
|||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
* @implements NodeNameResolverInterface<Variable>
|
||||
*/
|
||||
final class VariableNameResolver implements NodeNameResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return class-string<Node>
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return Variable::class;
|
||||
|
|
|
@ -82,7 +82,7 @@ final class ScopeNestingComparator
|
|||
return false;
|
||||
}
|
||||
|
||||
$foundIfNode = $this->betterNodeFinder->find(
|
||||
$foundIfNode = (bool) $this->betterNodeFinder->findFirst(
|
||||
$foundParentNode->stmts,
|
||||
fn ($node): bool => $this->nodeComparator->areNodesEqual($node, $seekedExpr)
|
||||
);
|
||||
|
@ -91,7 +91,7 @@ final class ScopeNestingComparator
|
|||
return false;
|
||||
}
|
||||
|
||||
$foundElseNode = $this->betterNodeFinder->find(
|
||||
$foundElseNode = (bool) $this->betterNodeFinder->findFirst(
|
||||
$foundParentNode->else,
|
||||
fn ($node): bool => $this->nodeComparator->areNodesEqual($node, $seekedExpr)
|
||||
);
|
||||
|
|
|
@ -168,8 +168,8 @@ final class NodeTypeResolver
|
|||
$scope = $node->getAttribute(AttributeKey::SCOPE);
|
||||
|
||||
if (! $scope instanceof Scope) {
|
||||
if ($node instanceof ConstFetch && $node->name instanceof Name) {
|
||||
$name = (string) $node->name;
|
||||
if ($node instanceof ConstFetch) {
|
||||
$name = $node->name->toString();
|
||||
if (strtolower($name) === 'null') {
|
||||
return new NullType();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Cast;
|
||||
use PhpParser\Node\Expr\Cast\Array_;
|
||||
use PhpParser\Node\Expr\Cast\Bool_;
|
||||
|
@ -23,6 +24,9 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<Cast>
|
||||
*/
|
||||
final class CastTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
/**
|
||||
|
@ -36,7 +40,7 @@ final class CastTypeResolver implements NodeTypeResolverInterface
|
|||
];
|
||||
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return array<class-string<Expr>>
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -18,11 +18,13 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
|||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\ClassAndInterfaceTypeResolver\ClassTypeResolverTest
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\ClassAndInterfaceTypeResolver\InterfaceTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<Class_|Interface_>
|
||||
*/
|
||||
final class ClassAndInterfaceTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -16,6 +16,9 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
|||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<ClassMethod|ClassConst>
|
||||
*/
|
||||
final class ClassMethodOrClassConstTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
private NodeTypeResolver $nodeTypeResolver;
|
||||
|
@ -26,13 +29,13 @@ final class ClassMethodOrClassConstTypeResolver implements NodeTypeResolverInter
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireClassMethodOrClassConstTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
|||
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\NameTypeResolver\NameTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<Name|FullyQualified>
|
||||
*/
|
||||
final class NameTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
|
@ -21,6 +22,9 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
|||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<New_>
|
||||
*/
|
||||
final class NewTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -30,7 +34,7 @@ final class NewTypeResolver implements NodeTypeResolverInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return array<class-string<Expr>>
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -27,6 +27,8 @@ use Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
|||
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\ParamTypeResolver\ParamTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<Param>
|
||||
*/
|
||||
final class ParamTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
|
@ -43,10 +45,8 @@ final class ParamTypeResolver implements NodeTypeResolverInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireParamTypeResolver(
|
||||
NodeTypeResolver $nodeTypeResolver,
|
||||
StaticTypeMapper $staticTypeMapper
|
||||
): void {
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PHPStan\Analyser\Scope;
|
||||
|
@ -21,6 +22,8 @@ use Symfony\Contracts\Service\Attribute\Required;
|
|||
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\PropertyFetchTypeResolver\PropertyFetchTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<PropertyFetch>
|
||||
*/
|
||||
final class PropertyFetchTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
|
@ -34,13 +37,13 @@ final class PropertyFetchTypeResolver implements NodeTypeResolverInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowirePropertyFetchTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return array<class-string<Expr>>
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -16,13 +16,15 @@ use Symfony\Contracts\Service\Attribute\Required;
|
|||
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\PropertyTypeResolver\PropertyTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<Property>
|
||||
*/
|
||||
final class PropertyTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
private NodeTypeResolver $nodeTypeResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowirePropertyTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
|
|
@ -12,12 +12,15 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
|||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<Return_>
|
||||
*/
|
||||
final class ReturnTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
private NodeTypeResolver $nodeTypeResolver;
|
||||
|
||||
#[Required]
|
||||
public function autowireReturnTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Node\Scalar\DNumber;
|
||||
use PhpParser\Node\Scalar\Encapsed;
|
||||
|
@ -19,10 +20,13 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<Scalar>
|
||||
*/
|
||||
final class ScalarTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return array<class-string<Expr>>
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
@ -32,15 +36,15 @@ final class ScalarTypeResolver implements NodeTypeResolverInterface
|
|||
public function resolve(Node $node): Type
|
||||
{
|
||||
if ($node instanceof DNumber) {
|
||||
return new ConstantFloatType((float) $node->value);
|
||||
return new ConstantFloatType($node->value);
|
||||
}
|
||||
|
||||
if ($node instanceof String_) {
|
||||
return new ConstantStringType((string) $node->value);
|
||||
return new ConstantStringType($node->value);
|
||||
}
|
||||
|
||||
if ($node instanceof LNumber) {
|
||||
return new ConstantIntegerType((int) $node->value);
|
||||
return new ConstantIntegerType($node->value);
|
||||
}
|
||||
|
||||
if ($node instanceof MagicConst) {
|
||||
|
|
|
@ -19,6 +19,9 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
|||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements NodeTypeResolverInterface<StaticCall|MethodCall>
|
||||
*/
|
||||
final class StaticCallMethodCallTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
private NodeTypeResolver $nodeTypeResolver;
|
||||
|
@ -30,13 +33,13 @@ final class StaticCallMethodCallTypeResolver implements NodeTypeResolverInterfac
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireStaticCallMethodCallTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getNodeClasses(): array
|
||||
{
|
||||
|
|
|
@ -15,6 +15,8 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
|
|||
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\PerNodeTypeResolver\TraitTypeResolver\TraitTypeResolverTest
|
||||
*
|
||||
* @implements NodeTypeResolverInterface<Trait_>
|
||||
*/
|
||||
final class TraitTypeResolver implements NodeTypeResolverInterface
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ final class StatementNodeVisitor extends NodeVisitorAbstract
|
|||
|
||||
$currentStmt = $node->getAttribute(AttributeKey::CURRENT_STATEMENT);
|
||||
|
||||
if ($parent && ! $currentStmt) {
|
||||
if ($parent instanceof Node && ! $currentStmt instanceof Node) {
|
||||
$node->setAttribute(
|
||||
AttributeKey::PREVIOUS_STATEMENT,
|
||||
$parent->getAttribute(AttributeKey::PREVIOUS_STATEMENT)
|
||||
|
|
|
@ -56,7 +56,7 @@ final class ArrayTypeMapper implements TypeMapperInterface
|
|||
// To avoid circular dependency
|
||||
|
||||
#[Required]
|
||||
public function autowireArrayTypeMapper(
|
||||
public function autowire(
|
||||
PHPStanStaticTypeMapper $phpStanStaticTypeMapper,
|
||||
UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower,
|
||||
ReflectionProvider $reflectionProvider,
|
||||
|
|
|
@ -25,7 +25,7 @@ final class CallableTypeMapper implements TypeMapperInterface
|
|||
private PHPStanStaticTypeMapper $phpStanStaticTypeMapper;
|
||||
|
||||
#[Required]
|
||||
public function autowireCallableTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ final class ClassStringTypeMapper implements TypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireClassStringTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ final class ClosureTypeMapper implements TypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireClosureTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ final class IntersectionTypeMapper implements TypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireIntersectionTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ final class IterableTypeMapper implements TypeMapperInterface
|
|||
private PHPStanStaticTypeMapper $phpStanStaticTypeMapper;
|
||||
|
||||
#[Required]
|
||||
public function autowireIterableTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ final class ObjectTypeMapper implements TypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireObjectTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ final class UnionTypeMapper implements TypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireUnionTypeMapper(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
|
||||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\PhpAttribute\AnnotationToAttributeMapper;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
/**
|
||||
* @implements AnnotationToAttributeMapperInterface<array>
|
||||
* @implements AnnotationToAttributeMapperInterface<mixed[]>
|
||||
*/
|
||||
final class ArrayAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface
|
||||
{
|
||||
|
@ -31,10 +32,9 @@ final class ArrayAnnotationToAttributeMapper implements AnnotationToAttributeMap
|
|||
|
||||
/**
|
||||
* @param mixed[] $value
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function map($value): array
|
||||
public function map($value): array|Expr
|
||||
{
|
||||
return array_map(fn ($item): mixed => $this->annotationToAttributeMapper->map($item), $value);
|
||||
return array_map(fn ($item): Expr|array => $this->annotationToAttributeMapper->map($item), $value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\PhpAttribute\AnnotationToAttributeMapper;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
|
||||
use Rector\PhpAttribute\AnnotationToAttributeMapper;
|
||||
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
|
||||
|
@ -32,9 +33,8 @@ final class CurlyListNodeAnnotationToAttributeMapper implements AnnotationToAttr
|
|||
|
||||
/**
|
||||
* @param CurlyListNode $value
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function map($value): array
|
||||
public function map($value): array|Expr
|
||||
{
|
||||
return array_map(
|
||||
fn ($node): mixed => $this->annotationToAttributeMapper->map($node),
|
||||
|
|
|
@ -15,7 +15,6 @@ interface AnnotationToAttributeMapperInterface
|
|||
|
||||
/**
|
||||
* @param T $value
|
||||
* @return Expr|Expr[]
|
||||
*/
|
||||
public function map($value): array|Expr;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ final class NameScopeFactory
|
|||
// This is needed to avoid circular references
|
||||
|
||||
#[Required]
|
||||
public function autowireNameScopeFactory(
|
||||
public function autowire(
|
||||
PhpDocInfoFactory $phpDocInfoFactory,
|
||||
StaticTypeMapper $staticTypeMapper,
|
||||
BetterNodeFinder $betterNodeFinder,
|
||||
|
|
|
@ -27,7 +27,7 @@ final class IntersectionTypeMapper implements PhpDocTypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireUnionTypeMapper(PhpDocTypeMapper $phpDocTypeMapper): void
|
||||
public function autowire(PhpDocTypeMapper $phpDocTypeMapper): void
|
||||
{
|
||||
$this->phpDocTypeMapper = $phpDocTypeMapper;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ final class UnionTypeMapper implements PhpDocTypeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireUnionTypeMapper(PhpDocTypeMapper $phpDocTypeMapper): void
|
||||
public function autowire(PhpDocTypeMapper $phpDocTypeMapper): void
|
||||
{
|
||||
$this->phpDocTypeMapper = $phpDocTypeMapper;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ final class IntersectionTypeNodeMapper implements PhpParserNodeMapperInterface
|
|||
private PhpParserNodeMapper $phpParserNodeMapper;
|
||||
|
||||
#[Required]
|
||||
public function autowireUnionTypeNodeMapper(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
public function autowire(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
{
|
||||
$this->phpParserNodeMapper = $phpParserNodeMapper;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ final class NullableTypeNodeMapper implements PhpParserNodeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireNullableTypeNodeMapper(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
public function autowire(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
{
|
||||
$this->phpParserNodeMapper = $phpParserNodeMapper;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ final class UnionTypeNodeMapper implements PhpParserNodeMapperInterface
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireUnionTypeNodeMapper(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
public function autowire(PhpParserNodeMapper $phpParserNodeMapper): void
|
||||
{
|
||||
$this->phpParserNodeMapper = $phpParserNodeMapper;
|
||||
}
|
||||
|
|
47
phpstan.neon
47
phpstan.neon
|
@ -146,7 +146,6 @@ parameters:
|
|||
-
|
||||
message: '#If condition is always false#'
|
||||
paths:
|
||||
- rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php
|
||||
- rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php
|
||||
- packages/NodeNestingScope/NodeFinder/ScopeAwareNodeFinder.php
|
||||
|
||||
|
@ -259,11 +258,6 @@ parameters:
|
|||
|
||||
- '#Cognitive complexity for "Rector\\CodeQuality\\Rector\\Isset_\\IssetOnPropertyObjectToPropertyExistsRector\:\:refactor\(\)" is \d+, keep it under 10#'
|
||||
|
||||
-
|
||||
message: '#Argument and options "debug" got confused#'
|
||||
paths:
|
||||
- src/Console/Command/ProcessCommand.php
|
||||
|
||||
- '#(.*?) class\-string, string given#'
|
||||
|
||||
# part of refactor() API, node must be returned, or does bring any value
|
||||
|
@ -330,7 +324,6 @@ parameters:
|
|||
message: '#Function "function_exists\(\)" cannot be used/left in the code#'
|
||||
paths:
|
||||
- src/functions/node_helper.php
|
||||
- packages/NodeTypeResolver/PHPStan/CollisionGuard/MixinGuard.php
|
||||
|
||||
# special case - cleanup in the future
|
||||
-
|
||||
|
@ -358,11 +351,6 @@ parameters:
|
|||
# false positive
|
||||
- '#Attribute class JetBrains\\PhpStorm\\Immutable does not exist#'
|
||||
|
||||
# allowed for ease api
|
||||
-
|
||||
message: '#Cannot return include_once/require_once#'
|
||||
path: rules/Renaming/Rector/Name/RenameClassRector.php
|
||||
|
||||
# class-string miss match
|
||||
- '#Parameter \#1 \$classes of method Rector\\BetterPhpDocParser\\PhpDocInfo\\PhpDocInfo<PHPStan\\PhpDocParser\\Ast\\Node\>\:\:getByAnnotationClasses\(\) expects array<class\-string\>, array<int, string\> given#'
|
||||
- '#Parameter \#1 \$classes of method Rector\\BetterPhpDocParser\\PhpDocInfo\\PhpDocInfo<TNode of PHPStan\\PhpDocParser\\Ast\\Node\>\:\:getByAnnotationClasses\(\) expects array<class\-string\>, array<string\> given#'
|
||||
|
@ -509,12 +497,6 @@ parameters:
|
|||
path: rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php
|
||||
message: '#Class cognitive complexity is 31, keep it under 30#'
|
||||
|
||||
-
|
||||
message: '#Autowired/inject method name must respect "autowire/inject" \+ class name#'
|
||||
paths:
|
||||
- packages/StaticTypeMapper/PhpDocParser/IntersectionTypeMapper.php
|
||||
- packages/StaticTypeMapper/PhpParser/IntersectionTypeNodeMapper.php
|
||||
|
||||
-
|
||||
message: '#Use separate function calls with readable variable names#'
|
||||
path: src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php
|
||||
|
@ -523,9 +505,6 @@ parameters:
|
|||
message: '#\$service\-\>call\("configure", \[\[ \.\.\. \]\]\) must be followed by exact array#'
|
||||
path: src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php
|
||||
|
||||
# this rule should only check parent autowire override case, @todo update in symplify
|
||||
- '#Autowired/inject method name must respect "autowire/inject" \+ class name#'
|
||||
|
||||
# on purpose to make use of worker paralle pattern
|
||||
-
|
||||
message: '#Instead of abstract class, use specific service with composition#'
|
||||
|
@ -581,9 +560,6 @@ parameters:
|
|||
- '#Method Rector\\Core\\PhpParser\\NodeTraverser\\RectorNodeTraverser\:\:traverse\(\) should return array<TNode of PhpParser\\Node\> but returns array<PhpParser\\Node\>#'
|
||||
- '#Parameter \#1 \$stmts of class Rector\\Core\\PhpParser\\Node\\CustomNode\\FileWithoutNamespace constructor expects array<PhpParser\\Node\\Stmt\>, array<TNode of PhpParser\\Node\> given#'
|
||||
|
||||
# skip === false compare
|
||||
- '#Do not compare call directly, use a variable assign#'
|
||||
|
||||
# strict - resolve later
|
||||
- '#Foreach overwrites \$(.*?) with its value variable#'
|
||||
|
||||
|
@ -592,10 +568,25 @@ parameters:
|
|||
path: rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php
|
||||
|
||||
# stricter child type on purpose
|
||||
- '#Parameter \#1 \$tokenIterator \(Rector\\BetterPhpDocParser\\ValueObject\\Parser\\BetterTokenIterator\) of method Rector\\BetterPhpDocParser\\PhpDocParser\\BetterPhpDocParser\:\:parseTagValue\(\) should be contravariant with parameter \$tokens \(PHPStan\\PhpDocParser\\Parser\\TokenIterator\) of method PHPStan\\PhpDocParser\\Parser\\PhpDocParser\:\:parseTagValue\(\)#'
|
||||
|
||||
# on purpose
|
||||
- '#Instead of "instanceof/is_a\(\)" use ReflectionProvider service or "\(new ObjectType\(<desired_type\>\)\)\-\>isSuperTypeOf\(<element_type\>\)" for static reflection to work#'
|
||||
- '#Parameter \#1 \$nodes \(array<PhpParser\\Node\\Stmt\>\) of method Rector\\PostRector\\Rector\\(.*?)\:\:beforeTraverse\(\) should be contravariant with parameter \$nodes \(array<PhpParser\\Node\>\) of method PhpParser\\NodeVisitor\:\:beforeTraverse\(\)#'
|
||||
|
||||
# stricter child type on purpose
|
||||
- '#Parameter \#1 \$tokenIterator \(Rector\\BetterPhpDocParser\\ValueObject\\Parser\\BetterTokenIterator\) of method Rector\\BetterPhpDocParser\\PhpDocParser\\BetterPhpDocParser\:\:parseTagValue\(\) should be contravariant with parameter \$tokens \(PHPStan\\PhpDocParser\\Parser\\TokenIterator\) of method PHPStan\\PhpDocParser\\Parser\\PhpDocParser\:\:parseTagValue\(\)#'
|
||||
- '#Parameter \#1 \$nodes \(array<PhpParser\\Node\\Stmt\>\) of method Rector\\PostRector\\Rector\\(.*?)\:\:beforeTraverse\(\) should be contravariant with parameter \$nodes \(array<PhpParser\\Node\>\) of method PhpParser\\NodeVisitorAbstract\:\:beforeTraverse\(\)#'
|
||||
|
||||
# property changed else-where
|
||||
-
|
||||
message: '#If condition is always false#'
|
||||
path: rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php
|
||||
|
||||
# on purpose, allows empty tokens
|
||||
- '#Rector\\BetterPhpDocParser\\ValueObject\\Parser\\BetterTokenIterator\:\:__construct\(\) does not call parent constructor from PHPStan\\PhpDocParser\\Parser\\TokenIterator#'
|
||||
- '#Rector\\Comments\\NodeTraverser\\CommentRemovingNodeTraverser\:\:__construct\(\) does not call parent constructor from PhpParser\\NodeTraverser#'
|
||||
|
||||
# resolve later
|
||||
- '#Method Rector\\PhpAttribute\\AnnotationToAttributeMapper\\CurlyListNodeAnnotationToAttributeMapper\:\:map\(\) should return array<PhpParser\\Node\\Expr\>\|PhpParser\\Node\\Expr but returns array<int\|string, array<PhpParser\\Node\\Expr\>\|PhpParser\\Node\\Expr\>#'
|
||||
|
||||
# always Expr or mixed nested array
|
||||
- '#Method Rector\\PhpAttribute\\Contract\\AnnotationToAttributeMapperInterface\:\:map\(\) return type has no value type specified in iterable type array#'
|
||||
- '#Method Rector\\PhpAttribute\\AnnotationToAttributeMapper\\(.*?)AnnotationToAttributeMapper\:\:map\(\) return type has no value type specified in iterable type array#'
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class WithRequiredAnnotation
|
|||
private $visibilityManipulator;
|
||||
|
||||
/** @required */
|
||||
public function autowireSomeService(VisibilityManipulator $visibilityManipulator)
|
||||
public function autowire(VisibilityManipulator $visibilityManipulator)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class WithRequiredAnnotation
|
|||
private $visibilityManipulator;
|
||||
|
||||
/** @required */
|
||||
public function autowireSomeService()
|
||||
public function autowire()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class WithRequiredAttribute
|
|||
private $visibilityManipulator;
|
||||
|
||||
#[Required]
|
||||
public function autowireSomeService(VisibilityManipulator $visibilityManipulator)
|
||||
public function autowire(VisibilityManipulator $visibilityManipulator)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class WithRequiredAttribute
|
|||
private $visibilityManipulator;
|
||||
|
||||
#[Required]
|
||||
public function autowireSomeService()
|
||||
public function autowire()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use Symfony\Contracts\Service\Attribute\Required;
|
|||
class SkipAutowiredMethod
|
||||
{
|
||||
#[Required]
|
||||
public function autowireSomeMethod(NodeNameResolver $nodeNameResolver)
|
||||
public function autowire(NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class SkipAutowiredMethodAnnotation
|
|||
/**
|
||||
* @required
|
||||
*/
|
||||
public function autowireSomeMethod(NodeNameResolver $nodeNameResolver)
|
||||
public function autowire(NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ final class ShortNameResolver
|
|||
// Avoids circular reference
|
||||
|
||||
#[Required]
|
||||
public function autowireShortNameResolver(PhpDocInfoFactory $phpDocInfoFactory): void
|
||||
public function autowire(PhpDocInfoFactory $phpDocInfoFactory): void
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use Rector\CodingStyle\ClassNameImport\AliasUsesResolver;
|
|||
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PostRector\Collector\UseNodesToAddCollector;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
|
@ -33,7 +32,6 @@ final class NameImporter
|
|||
public function __construct(
|
||||
private AliasUsesResolver $aliasUsesResolver,
|
||||
private ClassNameImportSkipper $classNameImportSkipper,
|
||||
private NodeNameResolver $nodeNameResolver,
|
||||
private ParameterProvider $parameterProvider,
|
||||
private StaticTypeMapper $staticTypeMapper,
|
||||
private UseNodesToAddCollector $useNodesToAddCollector,
|
||||
|
@ -70,7 +68,7 @@ final class NameImporter
|
|||
|
||||
private function shouldSkipName(Name $name): bool
|
||||
{
|
||||
$virtualNode = $name->getAttribute(AttributeKey::VIRTUAL_NODE);
|
||||
$virtualNode = (bool) $name->getAttribute(AttributeKey::VIRTUAL_NODE, false);
|
||||
if ($virtualNode) {
|
||||
return true;
|
||||
}
|
||||
|
@ -92,8 +90,8 @@ final class NameImporter
|
|||
|
||||
// Importing root namespace classes (like \DateTime) is optional
|
||||
if (! $this->parameterProvider->provideBoolParameter(Option::IMPORT_SHORT_CLASSES)) {
|
||||
$stringName = $this->nodeNameResolver->getName($name);
|
||||
if ($stringName !== null && substr_count($stringName, '\\') === 0) {
|
||||
$stringName = $name->toString();
|
||||
if (substr_count($stringName, '\\') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,7 @@ final class ConditionEvaluator
|
|||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|int|null
|
||||
*/
|
||||
public function evaluate(ConditionInterface $condition)
|
||||
public function evaluate(ConditionInterface $condition): bool|int|null
|
||||
{
|
||||
if ($condition instanceof VersionCompareCondition) {
|
||||
return $this->evaluateVersionCompareCondition($condition);
|
||||
|
|
|
@ -34,7 +34,7 @@ final class SomeService
|
|||
private $visibilityManipulator;
|
||||
|
||||
#[Required]
|
||||
public function autowireSomeService(VisibilityManipulator $visibilityManipulator)
|
||||
public function autowire(VisibilityManipulator $visibilityManipulator)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ final class SomeService
|
|||
private $visibilityManipulator;
|
||||
|
||||
#[Required]
|
||||
public function autowireSomeService()
|
||||
public function autowire()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,11 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
// if is skipped
|
||||
if ($result) {
|
||||
if ($result === true) {
|
||||
return $this->refactorIsMatch($node);
|
||||
}
|
||||
|
||||
if ($result > 0) {
|
||||
return $this->refactorIsMatch($node);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ final class PhpSpecMethodToPHPUnitMethodRector extends AbstractPhpSpecToPHPUnitR
|
|||
// reorder instantiation + expected exception
|
||||
$previousStmt = null;
|
||||
foreach ((array) $classMethod->stmts as $key => $stmt) {
|
||||
$printedStmt = $this->print($stmt);
|
||||
$printedStmtContent = $this->print($stmt);
|
||||
|
||||
if ($previousStmt && \str_contains($printedStmt, 'duringInstantiation')) {
|
||||
if (\str_contains($printedStmtContent, 'duringInstantiation')) {
|
||||
$printedPreviousStmt = $this->print($previousStmt);
|
||||
if (\str_contains($printedPreviousStmt, 'beConstructedThrough')) {
|
||||
$classMethod->stmts[$key - 1] = $stmt;
|
||||
|
|
|
@ -137,7 +137,7 @@ final class PropertyFetchByMethodAnalyzer
|
|||
return null;
|
||||
}
|
||||
|
||||
$isPropertyReadInIf = $this->verifyPropertyReadInIf($isPropertyReadInIf, $node, $propertyName);
|
||||
$isPropertyReadInIf = $this->isPropertyReadInNode($isPropertyReadInIf, $node, $propertyName);
|
||||
$isPropertyChanging = $this->isPropertyChanging($node, $propertyName);
|
||||
|
||||
if (! $isPropertyChanging) {
|
||||
|
@ -151,10 +151,10 @@ final class PropertyFetchByMethodAnalyzer
|
|||
return $isPropertyChanging || $isIfFollowedByAssign || $isPropertyReadInIf;
|
||||
}
|
||||
|
||||
private function verifyPropertyReadInIf(?bool $isPropertyReadInIf, Node $node, string $propertyName): ?bool
|
||||
private function isPropertyReadInNode(bool $isPropertyReadInIf, Node $node, string $propertyName): bool
|
||||
{
|
||||
if ($node instanceof If_) {
|
||||
return $this->refactorIf($node, $propertyName);
|
||||
return $this->isPropertyReadInIf($node, $propertyName);
|
||||
}
|
||||
|
||||
return $isPropertyReadInIf;
|
||||
|
@ -171,13 +171,15 @@ final class PropertyFetchByMethodAnalyzer
|
|||
return false;
|
||||
}
|
||||
|
||||
private function refactorIf(If_ $if, string $privatePropertyName): ?bool
|
||||
private function isPropertyReadInIf(If_ $if, string $propertyName): bool
|
||||
{
|
||||
$isPropertyReadInIf = false;
|
||||
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($if->cond, function (Node $node) use (
|
||||
$privatePropertyName,
|
||||
$propertyName,
|
||||
&$isPropertyReadInIf
|
||||
): ?int {
|
||||
if (! $this->propertyFetchAnalyzer->isLocalPropertyOfNames($node, [$privatePropertyName])) {
|
||||
if (! $this->propertyFetchAnalyzer->isLocalPropertyOfNames($node, [$propertyName])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ final class PHPUnitDataProviderParamTypeInferer implements ParamTypeInfererInter
|
|||
// Prevents circular reference
|
||||
|
||||
#[Required]
|
||||
public function autowirePHPUnitDataProviderParamTypeInferer(NodeTypeResolver $nodeTypeResolver): void
|
||||
public function autowire(NodeTypeResolver $nodeTypeResolver): void
|
||||
{
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ final class CallAnalyzer
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireCallAnalyzer(BetterNodeFinder $betterNodeFinder): void
|
||||
public function autowire(BetterNodeFinder $betterNodeFinder): void
|
||||
{
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorIn
|
|||
private RectifiedAnalyzer $rectifiedAnalyzer;
|
||||
|
||||
#[Required]
|
||||
public function autowireAbstractRector(
|
||||
public function autowire(
|
||||
NodesToRemoveCollector $nodesToRemoveCollector,
|
||||
NodesToAddCollector $nodesToAddCollector,
|
||||
RectorChangeCollector $rectorChangeCollector,
|
||||
|
|
|
@ -35,7 +35,7 @@ final class ParentAttributeSourceLocator implements SourceLocator
|
|||
}
|
||||
|
||||
#[Required]
|
||||
public function autowireParentAttributeSourceLocator(AstResolver $astResolver): void
|
||||
public function autowire(AstResolver $astResolver): void
|
||||
{
|
||||
$this->astResolver = $astResolver;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user