-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Remove obsolete methods from TypeConverters
- Loading branch information
1 parent
604c6dc
commit 53a4759
Showing
9 changed files
with
152 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\NodeVisitor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\ClassMethod; | ||
use PhpParser\NodeTraverser; | ||
use PhpParser\NodeVisitor; | ||
use Rector\NodeNameResolver\NodeNameResolver; | ||
|
||
final class RemoveExtbaseTypeConverterNodeVisitor implements NodeVisitor | ||
{ | ||
private NodeNameResolver $nodeNameResolver; | ||
|
||
public function __construct(NodeNameResolver $nodeNameResolver) | ||
{ | ||
$this->nodeNameResolver = $nodeNameResolver; | ||
} | ||
|
||
public function beforeTraverse(array $nodes): ?array | ||
{ | ||
return $nodes; | ||
} | ||
|
||
public function enterNode(Node $node): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
public function leaveNode(Node $node) | ||
{ | ||
if (! $node instanceof ClassMethod) { | ||
return $node; | ||
} | ||
|
||
if (! $this->nodeNameResolver->isNames( | ||
$node->name, | ||
['getSupportedSourceTypes', 'getSupportedTargetType', 'getPriority'] | ||
)) { | ||
return $node; | ||
} | ||
|
||
return NodeTraverser::REMOVE_NODE; | ||
} | ||
|
||
public function afterTraverse(array $nodes): ?array | ||
{ | ||
return $nodes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...terExtbaseTypeConvertersAsServicesRector/Fixture/ExpectedMySecondSpecialTypeConverter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace Ssch\TYPO3Rector\Tests\Rector\v12\v0\typo3\RegisterExtbaseTypeConvertersAsServicesRector\Source; | ||
|
||
use TYPO3\CMS\Extbase\Property\TypeConverterInterface; | ||
final class MySecondSpecialTypeConverter implements TypeConverterInterface | ||
{ | ||
public function canConvertFrom($source, string $targetType): bool | ||
{ | ||
return false; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../RegisterExtbaseTypeConvertersAsServicesRector/Fixture/ExpectedMySpecialTypeConverter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace Ssch\TYPO3Rector\Tests\Rector\v12\v0\typo3\RegisterExtbaseTypeConvertersAsServicesRector\Source; | ||
|
||
use TYPO3\CMS\Extbase\Property\TypeConverterInterface; | ||
final class MySpecialTypeConverter implements TypeConverterInterface | ||
{ | ||
public function canConvertFrom($source, string $targetType): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ services: | |
tags: | ||
name: extbase.type_converter | ||
sources: array | ||
target: int | ||
target: MySpecialEntity | ||
priority: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...tor/v12/v0/typo3/RegisterExtbaseTypeConvertersAsServicesRector/Source/MySpecialEntity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\v12\v0\typo3\RegisterExtbaseTypeConvertersAsServicesRector\Source; | ||
|
||
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; | ||
|
||
final class MySpecialEntity extends AbstractEntity | ||
{ | ||
} |