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: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
"tests/Source",
"tests/Rector/Psr4/MultipleClassFileToPsr4ClassesRector/Source",
"tests/Rector/Namespace_/PseudoNamespaceToNamespaceRector/Source",
"stubs",
"tests/Issues/Issue1243/Source",
"packages/Autodiscovery/tests/Rector/FileSystem/MoveInterfacesToContractNamespaceDirectoryRector/Expected",
"packages/Autodiscovery/tests/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector/Expected"
Expand Down
2 changes: 1 addition & 1 deletion docs/AllRectorsOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6427,7 +6427,7 @@ Move self::$container service fetching from test methods up to setUp method

- class: `Rector\Twig\Rector\SimpleFunctionAndFilterRector`

Changes Twig_Function_Method to Twig_SimpleFunction calls in TwigExtension.
Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.

```diff
class SomeExtension extends Twig_Extension
Expand Down
4 changes: 4 additions & 0 deletions ecs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ parameters:
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer:
# buggy with PHP heredoc
- 'packages/SOLID/src/Rector/ClassConst/PrivatizeLocalClassConstantRector.php'

Symplify\CodingStandard\Sniffs\Commenting\AnnotationTypeExistsSniff:
- '*PhpDocNodeFactory.php'
- '*AnnotationReader.php'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rector\DeadCode\Rector\Class_;

use Doctrine\Common\Collections\ArrayCollection;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\New_;
Expand All @@ -10,7 +11,6 @@
use PhpParser\Node\Stmt\Property;
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
use Rector\DeadCode\UnusedNodeResolver\ClassUnusedPrivateClassMethodResolver;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\NodeContainer\ParsedNodesByType;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PhpParser\Node\Manipulator\ClassManipulator;
Expand Down Expand Up @@ -241,7 +241,7 @@ private function isPropertyFetchAssignOfArrayCollection(PropertyFetch $propertyF
/** @var New_ $new */
$new = $parentNode->expr;

return $this->isName($new->class, DoctrineClass::ARRAY_COLLECTION);
return $this->isName($new->class, ArrayCollection::class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Ramsey\Uuid\UuidInterface;
use Rector\BetterPhpDocParser\Attributes\Ast\PhpDoc\SpacelessPhpDocTagNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\ColumnTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\GeneratedValueTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\IdTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\JoinColumnTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\JoinTableTagValueNode;
use Rector\Doctrine\Uuid\JoinTableNameResolver;
use Rector\Doctrine\ValueObject\DoctrineClass;

final class PhpDocTagNodeFactory
{
Expand All @@ -29,7 +29,7 @@ public function __construct(JoinTableNameResolver $joinTableNameResolver)

public function createVarTagUuidInterface(): PhpDocTagNode
{
$identifierTypeNode = new IdentifierTypeNode('\\' . DoctrineClass::RAMSEY_UUID_INTERFACE);
$identifierTypeNode = new IdentifierTypeNode('\\' . UuidInterface::class);
$varTagValueNode = new VarTagValueNode($identifierTypeNode, '', '');

return new PhpDocTagNode('@var', $varTagValueNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Ramsey\Uuid\UuidInterface;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\RectorDefinition;

Expand Down Expand Up @@ -45,12 +45,12 @@ public function refactor(Node $node): ?Node
// is already set?
if ($node->returnType) {
$currentType = $this->getName($node->returnType);
if ($currentType === DoctrineClass::RAMSEY_UUID_INTERFACE) {
if ($currentType === UuidInterface::class) {
return null;
}
}

$node->returnType = new FullyQualified(DoctrineClass::RAMSEY_UUID_INTERFACE);
$node->returnType = new FullyQualified(UuidInterface::class);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Return_;
use Ramsey\Uuid\UuidInterface;
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function refactor(Node $node): ?Node
return null;
}

$node->returnType = new FullyQualified(DoctrineClass::RAMSEY_UUID_INTERFACE);
$node->returnType = new FullyQualified(UuidInterface::class);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Ramsey\Uuid\UuidInterface;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\RectorDefinition;

Expand Down Expand Up @@ -48,12 +48,12 @@ public function refactor(Node $node): ?Node
// is already set?
if ($node->params[0]->type) {
$currentType = $this->getName($node->params[0]->type);
if ($currentType === DoctrineClass::RAMSEY_UUID_INTERFACE) {
if ($currentType === UuidInterface::class) {
return null;
}
}

$node->params[0]->type = new FullyQualified(DoctrineClass::RAMSEY_UUID_INTERFACE);
$node->params[0]->type = new FullyQualified(UuidInterface::class);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Rector\Doctrine\Rector\Class_;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\MethodCall;
Expand All @@ -15,7 +18,6 @@
use PhpParser\Node\Stmt\Property;
use PhpParser\NodeTraverser;
use PHPStan\Type\ObjectType;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\PHPStan\Type\FullyQualifiedObjectType;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
Expand All @@ -26,24 +28,6 @@
*/
final class ManagerRegistryGetManagerToEntityManagerRector extends AbstractRector
{
/**
* @var string
*/
private $managerRegistryClass;

/**
* @var string
*/
private $objectManagerClass;

public function __construct(
string $managerRegistryClass = DoctrineClass::MANAGER_REGISTRY,
string $objectManagerClass = DoctrineClass::OBJECT_MANAGER
) {
$this->managerRegistryClass = $managerRegistryClass;
$this->objectManagerClass = $objectManagerClass;
}

public function getDefinition(): RectorDefinition
{
return new RectorDefinition('', [
Expand Down Expand Up @@ -140,7 +124,7 @@ public function refactor(Node $node): ?Node
$node,
$constructMethodNode,
'entityManager',
new FullyQualifiedObjectType(DoctrineClass::ENTITY_MANAGER)
new FullyQualifiedObjectType(EntityManagerInterface::class)
);

return $node;
Expand All @@ -152,7 +136,7 @@ private function isRegistryGetManagerMethodCall(Assign $assign): bool
return false;
}

if (! $this->isObjectType($assign->expr->var, $this->managerRegistryClass)) {
if (! $this->isObjectType($assign->expr->var, ManagerRegistry::class)) {
return false;
}

Expand Down Expand Up @@ -183,7 +167,7 @@ private function removeAssignGetRepositoryCalls(Class_ $class): void

private function createEntityManagerParam(): Param
{
return new Param(new Variable('entityManager'), null, new FullyQualified(DoctrineClass::ENTITY_MANAGER));
return new Param(new Variable('entityManager'), null, new FullyQualified(EntityManagerInterface::class));
}

/**
Expand All @@ -197,7 +181,7 @@ private function resolveManagerRegistryCalledMethodNames(Class_ $class): array
return null;
}

if (! $this->isObjectType($node->var, $this->managerRegistryClass)) {
if (! $this->isObjectType($node->var, ManagerRegistry::class)) {
return null;
}

Expand All @@ -223,7 +207,7 @@ private function removeManagerRegistryDependency(
continue;
}

if (! $this->isName($param->type, $this->managerRegistryClass)) {
if (! $this->isName($param->type, ManagerRegistry::class)) {
continue;
}

Expand Down Expand Up @@ -252,7 +236,7 @@ private function resolveManagerRegistryParam(ClassMethod $classMethod): ?Param
continue;
}

if (! $this->isName($param->type, $this->managerRegistryClass)) {
if (! $this->isName($param->type, ManagerRegistry::class)) {
continue;
}

Expand Down Expand Up @@ -331,7 +315,7 @@ private function replaceEntityRegistryVariableWithEntityManagerProperty(Class_ $
return null;
}

if (! $this->isObjectType($node, $this->objectManagerClass)) {
if (! $this->isObjectType($node, ObjectManager::class)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PHPStan\Type\ObjectType;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
Expand Down Expand Up @@ -78,7 +79,7 @@ public function refactor(Node $node): ?Node

[$entityMethodCall, $comparedVariable] = $match;

$fromStringValue = $this->createStaticCall(DoctrineClass::RAMSEY_UUID, 'fromString', [$comparedVariable]);
$fromStringValue = $this->createStaticCall(Uuid::class, 'fromString', [$comparedVariable]);

return $this->createMethodCall($entityMethodCall, 'equals', [$fromStringValue]);
}
Expand All @@ -90,7 +91,7 @@ private function isAlreadyUuidType(Expr $expr): bool
return false;
}

return $comparedValueObjectType->getClassName() === DoctrineClass::RAMSEY_UUID_INTERFACE;
return $comparedValueObjectType->getClassName() === UuidInterface::class;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use PHPStan\Type\StringType;
use Ramsey\Uuid\Uuid;
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\NodeContainer\ParsedNodesByType;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;
Expand Down Expand Up @@ -212,7 +211,7 @@ private function isUuidType(Expr $expr): bool
return false;
}

return $argumentStaticType->getClassName() === DoctrineClass::RAMSEY_UUID;
return $argumentStaticType->getClassName() === Uuid::class;
}

private function createUuidStringNode(): String_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rector\Doctrine\Rector\MethodCall;

use Doctrine\ORM\EntityManagerInterface;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Scalar\String_;
Expand All @@ -19,20 +20,12 @@ final class EntityAliasToClassConstantReferenceRector extends AbstractRector
*/
private $aliasesToNamespaces = [];

/**
* @var string
*/
private $entityManagerClass;

/**
* @param string[] $aliasesToNamespaces
*/
public function __construct(
array $aliasesToNamespaces = [],
string $entityManagerClass = 'Doctrine\ORM\EntityManagerInterface'
) {
public function __construct(array $aliasesToNamespaces = [])
{
$this->aliasesToNamespaces = $aliasesToNamespaces;
$this->entityManagerClass = $entityManagerClass;
}

public function getDefinition(): RectorDefinition
Expand Down Expand Up @@ -65,7 +58,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectType($node, $this->entityManagerClass)) {
if (! $this->isObjectType($node, EntityManagerInterface::class)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use PhpParser\Node;
use PhpParser\Node\Stmt\Property;
use Ramsey\Uuid\UuidInterface;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\ColumnTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Property_\GeneratedValueTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\JMS\SerializerTypeTagValueNode;
use Rector\Doctrine\ValueObject\DoctrineClass;
use Rector\PHPStan\Type\FullyQualifiedObjectType;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\RectorDefinition;
Expand Down Expand Up @@ -61,7 +61,7 @@ public function refactor(Node $node): ?Node

private function changeVarToUuidInterface(Property $property): void
{
$uuidObjectType = new FullyQualifiedObjectType(DoctrineClass::RAMSEY_UUID_INTERFACE);
$uuidObjectType = new FullyQualifiedObjectType(UuidInterface::class);
$this->docBlockManipulator->changeVarTag($property, $uuidObjectType);
}

Expand Down
36 changes: 0 additions & 36 deletions packages/Doctrine/src/ValueObject/DoctrineClass.php

This file was deleted.

Loading