Skip to content

Commit 105ae61

Browse files
authored
[deprecated] Remove deprecated MakeEntityDateTimePropertyDateTimeInterfaceRector (#376)
1 parent 1da0aa0 commit 105ae61

11 files changed

Lines changed: 25 additions & 342 deletions

File tree

phpstan.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ parameters:
5353
# debug function
5454
- '#Function "d\(\)" cannot be used/left in the code#'
5555

56-
-
57-
identifier: classConstant.deprecatedClass
58-
path: rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php
59-
6056
-
6157
message: '#Parameter (.*?) \$desiredClass of method Rector\\BetterPhpDocParser\\PhpDocInfo\\PhpDocInfo::findByAnnotationClass\(\) expects class-string, string given#'
6258
path: src/NodeAnalyzer/AttrinationFinder.php

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/Fixture/fixture.php.inc

Lines changed: 0 additions & 51 deletions
This file was deleted.

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/Fixture/nullable_typed_property_datetime.php.inc

Lines changed: 0 additions & 41 deletions
This file was deleted.

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/Fixture/skip_date_time_interface.php.inc

Lines changed: 0 additions & 22 deletions
This file was deleted.

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/Fixture/skip_no_entity.php.inc

Lines changed: 0 additions & 13 deletions
This file was deleted.

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/MakeEntityDateTimePropertyDateTimeInterfaceRectorTest.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

rules-tests/CodeQuality/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector/config/configured_rule.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

rules/Bundle230/Rector/Class_/AddAnnotationToRepositoryRector.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace Rector\Doctrine\Bundle230\Rector\Class_;
66

7+
use PhpParser\Node\Name;
8+
use PhpParser\Node\Stmt\ClassMethod;
9+
use PhpParser\Node\Stmt\Expression;
10+
use PhpParser\Node\Expr\StaticCall;
11+
use PhpParser\Node\Identifier;
12+
use PhpParser\Node\Arg;
713
use PhpParser\Node;
814
use PhpParser\Node\Expr\ClassConstFetch;
915
use PhpParser\Node\Stmt\Class_;
@@ -21,14 +27,8 @@
2127
*/
2228
final class AddAnnotationToRepositoryRector extends AbstractRector
2329
{
24-
private DocBlockUpdater $docBlockUpdater;
25-
26-
private PhpDocInfoFactory $phpDocInfoFactory;
27-
28-
public function __construct(DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory)
30+
public function __construct(private readonly DocBlockUpdater $docBlockUpdater, private readonly PhpDocInfoFactory $phpDocInfoFactory)
2931
{
30-
$this->docBlockUpdater = $docBlockUpdater;
31-
$this->phpDocInfoFactory = $phpDocInfoFactory;
3232
}
3333

3434
public function getRuleDefinition(): RuleDefinition
@@ -80,14 +80,15 @@ public function refactor(Node $node): ?Node
8080
if ($entityClass === null || $this->hasExtendsAnnotation($node)) {
8181
return null;
8282
}
83+
8384
$this->addAnnotationToNode($node, $entityClass);
8485

8586
return $node;
8687
}
8788

8889
private function isRepositoryClass(Class_ $class): bool
8990
{
90-
if ($class->extends instanceof Node\Name) {
91+
if ($class->extends instanceof Name) {
9192
return $this->getName(
9293
$class->extends
9394
) === 'Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository';
@@ -99,17 +100,17 @@ private function isRepositoryClass(Class_ $class): bool
99100
private function getEntityClassFromConstructor(Class_ $class): ?string
100101
{
101102
$method = $class->getMethod(MethodName::CONSTRUCT);
102-
if ($method === null || $method->stmts === null) {
103+
if (!$method instanceof ClassMethod || $method->stmts === null) {
103104
return null;
104105
}
105106

106107
foreach ($method->stmts as $stmt) {
107-
if (! $stmt instanceof Node\Stmt\Expression) {
108+
if (! $stmt instanceof Expression) {
108109
continue;
109110
}
110111

111112
$expr = $stmt->expr;
112-
if (! $expr instanceof Node\Expr\StaticCall) {
113+
if (! $expr instanceof StaticCall) {
113114
continue;
114115
}
115116

@@ -124,7 +125,7 @@ private function getEntityClassFromConstructor(Class_ $class): ?string
124125

125126
$entityClass = $entityClassNode->class;
126127

127-
return $entityClass instanceof Node\Name
128+
return $entityClass instanceof Name
128129
? $entityClass->toString()
129130
: null;
130131
}
@@ -147,14 +148,14 @@ private function hasExtendsAnnotation(Class_ $class): bool
147148
->hasByName('@extends');
148149
}
149150

150-
private function isParentConstructorCall(Node\Expr\StaticCall $expr): bool
151+
private function isParentConstructorCall(StaticCall $staticCall): bool
151152
{
152-
return $expr->class instanceof Node\Name
153-
&& $expr->class->toString() === 'parent'
154-
&& $expr->name instanceof Node\Identifier
155-
&& $expr->name->toString() === '__construct'
156-
&& isset($expr->args[1])
157-
&& $expr->args[1] instanceof Node\Arg // Controleer of args[1] een Node\Arg is
158-
&& $expr->args[1]->value instanceof ClassConstFetch;
153+
return $staticCall->class instanceof Name
154+
&& $staticCall->class->toString() === 'parent'
155+
&& $staticCall->name instanceof Identifier
156+
&& $staticCall->name->toString() === '__construct'
157+
&& isset($staticCall->args[1])
158+
&& $staticCall->args[1] instanceof Arg // Controleer of args[1] een Node\Arg is
159+
&& $staticCall->args[1]->value instanceof ClassConstFetch;
159160
}
160161
}

0 commit comments

Comments
 (0)