mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 08:20:53 +00:00
Make use of File object instead of passing around provider of file info, tokens, stmts etc. (#6110)
Co-authored-by: kaizen-ci <info@kaizen-ci.org>
This commit is contained in:
parent
b0dc20a462
commit
8b402bfe02
|
@ -43,7 +43,6 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::FILE_INFO,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::METHOD_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE,
|
||||
|
@ -62,7 +61,6 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::FILE_INFO,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
|
@ -71,7 +69,6 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::FILE_INFO,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::METHOD_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE,
|
||||
|
@ -90,7 +87,6 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::FILE_INFO,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
|
|
|
@ -103,8 +103,8 @@
|
|||
"classmap": [
|
||||
"stubs/Annotations",
|
||||
"stubs/Nette",
|
||||
"rules-tests/Autodiscovery/Rector/FileNode/MoveInterfacesToContractNamespaceDirectoryRector/Expected",
|
||||
"rules-tests/Autodiscovery/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/Expected",
|
||||
"rules-tests/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector/Expected",
|
||||
"rules-tests/Autodiscovery/Rector/Interface_/MoveInterfacesToContractNamespaceDirectoryRector/Expected",
|
||||
"rules-tests/CodingStyle/Rector/Namespace_/ImportFullyQualifiedNamesRector/Source",
|
||||
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source",
|
||||
"rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Source",
|
||||
|
|
|
@ -3,16 +3,13 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\FileNode\RenameTesterTestToPHPUnitToTestFileRector;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\Class_\RenameTesterTestToPHPUnitToTestFileRector;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(NetteTesterClassToPHPUnitClassRector::class);
|
||||
|
||||
$services->set(NetteAssertToPHPUnitAssertRector::class);
|
||||
|
||||
$services->set(RenameTesterTestToPHPUnitToTestFileRector::class);
|
||||
};
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\RenameSpecFileToTestFileRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\FileNode\RenameSpecFileToTestFileRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
|
@ -27,8 +27,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(PhpSpecClassToPHPUnitClassRector::class);
|
||||
|
||||
$services->set(AddMockPropertiesRector::class);
|
||||
|
||||
$services->set(MockVariableToPropertyFetchRector::class);
|
||||
|
||||
$services->set(RenameSpecFileToTestFileRector::class);
|
||||
};
|
||||
|
|
|
@ -302,7 +302,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
Move entities to Entity namespace
|
||||
|
||||
- class: [`Rector\Autodiscovery\Rector\FileNode\MoveEntitiesToEntityDirectoryRector`](../rules/Autodiscovery/Rector/FileNode/MoveEntitiesToEntityDirectoryRector.php)
|
||||
- class: [`Rector\Autodiscovery\Rector\Class_\MoveEntitiesToEntityDirectoryRector`](../rules/Autodiscovery/Rector/Class_/MoveEntitiesToEntityDirectoryRector.php)
|
||||
|
||||
```diff
|
||||
-// file: app/Controller/Product.php
|
||||
|
@ -327,7 +327,7 @@ Move entities to Entity namespace
|
|||
|
||||
Move interface to "Contract" namespace
|
||||
|
||||
- class: [`Rector\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector`](../rules/Autodiscovery/Rector/FileNode/MoveInterfacesToContractNamespaceDirectoryRector.php)
|
||||
- class: [`Rector\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector`](../rules/Autodiscovery/Rector/Class_/MoveInterfacesToContractNamespaceDirectoryRector.php)
|
||||
|
||||
```diff
|
||||
-// file: app/Exception/Rule.php
|
||||
|
@ -349,10 +349,10 @@ Move classes by their suffix to their own group/directory
|
|||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector`](../rules/Autodiscovery/Rector/FileNode/MoveServicesBySuffixToDirectoryRector.php)
|
||||
- class: [`Rector\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector`](../rules/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector.php)
|
||||
|
||||
```php
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
use Rector\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
|
@ -387,10 +387,10 @@ Move value object to ValueObject namespace/directory
|
|||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector`](../rules/Autodiscovery/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector.php)
|
||||
- class: [`Rector\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector`](../rules/Autodiscovery/Rector/Class_/MoveValueObjectsToValueObjectDirectoryRector.php)
|
||||
|
||||
```php
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Rector\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
|
@ -2244,7 +2244,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
|
||||
TestCase::class => 'prefer_self',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -2655,7 +2656,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [
|
||||
'EventSubscriberInterface' => ['getSubscribedEvents'],
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -4116,7 +4118,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [
|
||||
'ParentClassWithNewConstructor' => '__construct',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -7280,7 +7283,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [
|
||||
'ReservedObject' => 'SmartObject', 'Object' => 'AnotherSmartObject',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -7871,7 +7875,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [
|
||||
'fn' => 'someFunctionName',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -9675,7 +9680,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
||||
'App\SomeOldClass' => 'App\SomeNewClass',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -9720,7 +9726,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameConstantRector::OLD_TO_NEW_CONSTANTS => [
|
||||
'MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'OLD_CONSTANT' => 'NEW_CONSTANT',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -9759,7 +9766,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'view' => 'Laravel\Templating\render',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -9828,7 +9836,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [
|
||||
'SomeOldNamespace' => 'SomeNewNamespace',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -9958,7 +9967,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameStringRector::STRING_CHANGES => [
|
||||
'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10041,7 +10051,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
CompleteMissingDependencyInNewRector::CLASS_TO_INSTANTIATE_BY_TYPE => [
|
||||
'RandomDependency' => 'RandomDependency',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10231,7 +10242,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
AddInterfaceByParentRector::INTERFACE_BY_PARENT => [
|
||||
'SomeParent' => 'SomeInterface',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10267,7 +10279,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [
|
||||
'SomeTrait' => 'SomeInterface',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10515,7 +10528,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => [
|
||||
'php_sapi_name' => 'PHP_SAPI',
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10605,7 +10619,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
FuncCallToNewRector::FUNCTIONS_TO_NEWS => [
|
||||
'collection' => ['Collection'],
|
||||
|
||||
], ]]);
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10762,8 +10777,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
->call('configure', [[
|
||||
MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [
|
||||
'SomeOldInterface' => 'SomeInterface',
|
||||
|
||||
], ]]);
|
||||
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10833,8 +10849,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
->call('configure', [[
|
||||
MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [
|
||||
'someMethod' => 'someProperty',
|
||||
|
||||
], ]]);
|
||||
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -10872,8 +10889,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
->call('configure', [[
|
||||
MethodCallToReturnRector::METHOD_CALL_WRAPS => [
|
||||
'SomeClass' => ['deny'],
|
||||
|
||||
], ]]);
|
||||
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -11140,8 +11158,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
->call('configure', [[
|
||||
ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => [
|
||||
'Nette\Object' => ['Nette\SmartObject'],
|
||||
|
||||
], ]]);
|
||||
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -11612,8 +11631,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
->call('configure', [[
|
||||
ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [
|
||||
'SomeObject' => 'getPath',
|
||||
|
||||
], ]]);
|
||||
|
||||
]
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -12346,8 +12366,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
ChangePropertyVisibilityRector::PROPERTY_TO_VISIBILITY_BY_CLASS => [
|
||||
'FrameworkClass' => [
|
||||
'someProperty' => 2,
|
||||
|
||||
|
||||
|
||||
|
||||
], ], ]]);
|
||||
};
|
||||
```
|
||||
|
|
|
@ -15,8 +15,8 @@ final class AffectedFilesCollector
|
|||
|
||||
public function addFile(File $file): void
|
||||
{
|
||||
$fileInfo = $file->getSmartFileInfo();
|
||||
$this->affectedFiles[$fileInfo->getRealPath()] = $file;
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
$this->affectedFiles[$smartFileInfo->getRealPath()] = $file;
|
||||
}
|
||||
|
||||
public function getNext(): ?File
|
||||
|
@ -29,7 +29,7 @@ final class AffectedFilesCollector
|
|||
|
||||
public function removeFromList(File $file): void
|
||||
{
|
||||
$fileInfo = $file->getSmartFileInfo();
|
||||
unset($this->affectedFiles[$fileInfo->getRealPath()]);
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
unset($this->affectedFiles[$smartFileInfo->getRealPath()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ namespace Rector\ChangesReporting\Collector;
|
|||
|
||||
use PhpParser\Node;
|
||||
use Rector\ChangesReporting\ValueObject\RectorWithFileAndLineChange;
|
||||
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Logging\CurrentRectorProvider;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class RectorChangeCollector
|
||||
|
@ -24,9 +26,17 @@ final class RectorChangeCollector
|
|||
*/
|
||||
private $currentRectorProvider;
|
||||
|
||||
public function __construct(CurrentRectorProvider $currentRectorProvider)
|
||||
{
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
public function __construct(
|
||||
CurrentRectorProvider $currentRectorProvider,
|
||||
CurrentFileProvider $currentFileProvider
|
||||
) {
|
||||
$this->currentRectorProvider = $currentRectorProvider;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,19 +54,26 @@ final class RectorChangeCollector
|
|||
|
||||
public function notifyNodeFileInfo(Node $node): void
|
||||
{
|
||||
$fileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if (! $fileInfo instanceof SmartFileInfo) {
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
if (! $file instanceof File) {
|
||||
// this file was changed before and this is a sub-new node
|
||||
// array Traverse to all new nodes would have to be used, but it's not worth the performance
|
||||
return;
|
||||
}
|
||||
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
$currentRector = $this->currentRectorProvider->getCurrentRector();
|
||||
if (! $currentRector instanceof RectorInterface) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
$this->addRectorClassWithLine($currentRector, $fileInfo, $node->getLine());
|
||||
// @old
|
||||
$this->addRectorClassWithLine($currentRector, $smartFileInfo, $node->getLine());
|
||||
|
||||
// @new
|
||||
$rectorWithLineChange = new RectorWithLineChange($currentRector, $node->getLine());
|
||||
$file->addRectorClassWithLine($rectorWithLineChange);
|
||||
}
|
||||
|
||||
private function addRectorClassWithLine(RectorInterface $rector, SmartFileInfo $smartFileInfo, int $line): void
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\ChangesReporting\ValueObject;
|
||||
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
|
||||
final class RectorWithLineChange
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $line;
|
||||
|
||||
/**
|
||||
* @var RectorInterface
|
||||
*/
|
||||
private $rector;
|
||||
|
||||
public function __construct(RectorInterface $rector, int $line)
|
||||
{
|
||||
$this->rector = $rector;
|
||||
$this->line = $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<RectorInterface>
|
||||
*/
|
||||
public function getRectorClass(): string
|
||||
{
|
||||
return get_class($this->rector);
|
||||
}
|
||||
|
||||
public function getLine(): int
|
||||
{
|
||||
return $this->line;
|
||||
}
|
||||
}
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\FileSystemRector\Contract;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
interface FileWithNodesInterface
|
||||
{
|
||||
/**
|
||||
* @return Node[]
|
||||
* @return Stmt[]
|
||||
*/
|
||||
public function getNodes(): array;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use PhpParser\Node\Stmt\ClassLike;
|
|||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\Autodiscovery\Configuration\CategoryNamespaceProvider;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
|
||||
use Rector\PSR4\Collector\RenamedClassesCollector;
|
||||
use Rector\PSR4\FileInfoAnalyzer\FileInfoDeletionAnalyzer;
|
||||
|
@ -59,15 +60,14 @@ final class AddedFileWithNodesFactory
|
|||
$this->fileInfoDeletionAnalyzer = $fileInfoDeletionAnalyzer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
*/
|
||||
public function createWithDesiredGroup(
|
||||
SmartFileInfo $oldFileInfo,
|
||||
array $nodes,
|
||||
File $file,
|
||||
string $desiredGroupName
|
||||
): ?AddedFileWithNodes {
|
||||
$currentNamespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class);
|
||||
$fileNodes = $file->getNewStmts();
|
||||
|
||||
$currentNamespace = $this->betterNodeFinder->findFirstInstanceOf($fileNodes, Namespace_::class);
|
||||
|
||||
// file without namespace → skip
|
||||
if (! $currentNamespace instanceof Namespace_) {
|
||||
|
@ -102,7 +102,7 @@ final class AddedFileWithNodesFactory
|
|||
}
|
||||
|
||||
// 1. rename namespace
|
||||
$this->renameNamespace($nodes, $newNamespaceName);
|
||||
$this->renameNamespace($file->getNewStmts(), $newNamespaceName);
|
||||
|
||||
// 2. return changed nodes and new file destination
|
||||
$newFileDestination = $this->fileRelocationResolver->createNewFileDestination(
|
||||
|
@ -112,7 +112,7 @@ final class AddedFileWithNodesFactory
|
|||
);
|
||||
|
||||
// 3. update fully qualifed name of the class like - will be used further
|
||||
$classLike = $this->betterNodeFinder->findFirstInstanceOf($nodes, ClassLike::class);
|
||||
$classLike = $this->betterNodeFinder->findFirstInstanceOf($fileNodes, ClassLike::class);
|
||||
if (! $classLike instanceof ClassLike) {
|
||||
return null;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ final class AddedFileWithNodesFactory
|
|||
|
||||
$this->renamedClassesCollector->addClassRename($oldClassName, $newClassName);
|
||||
|
||||
return new AddedFileWithNodes($newFileDestination, $nodes);
|
||||
return new AddedFileWithNodes($newFileDestination, $fileNodes);
|
||||
}
|
||||
|
||||
private function createNewNamespaceName(string $desiredGroupName, Namespace_ $currentNamespace): string
|
||||
|
|
102
packages/NodeNameResolver/Error/InvalidNameNodeReporter.php
Normal file
102
packages/NodeNameResolver/Error/InvalidNameNodeReporter.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\NodeNameResolver\Error;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class InvalidNameNodeReporter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const FILE = 'file';
|
||||
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
/**
|
||||
* @var BetterStandardPrinter
|
||||
*/
|
||||
private $betterStandardPrinter;
|
||||
|
||||
public function __construct(
|
||||
CurrentFileProvider $currentFileProvider,
|
||||
BetterStandardPrinter $betterStandardPrinter
|
||||
) {
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall|StaticCall $node
|
||||
*/
|
||||
public function reportInvalidNodeForName(Node $node): void
|
||||
{
|
||||
$message = sprintf('Pick more specific node than "%s", e.g. "$node->name"', get_class($node));
|
||||
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
|
||||
if ($file instanceof File) {
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
$message .= PHP_EOL . PHP_EOL;
|
||||
$message .= sprintf(
|
||||
'Caused in "%s" file on line %d on code "%s"',
|
||||
$smartFileInfo->getRelativeFilePathFromCwd(),
|
||||
$node->getStartLine(),
|
||||
$this->betterStandardPrinter->print($node)
|
||||
);
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace();
|
||||
$rectorBacktrace = $this->matchRectorBacktraceCall($backtrace);
|
||||
|
||||
if ($rectorBacktrace) {
|
||||
// issues to find the file in prefixed
|
||||
if (file_exists($rectorBacktrace[self::FILE])) {
|
||||
$smartFileInfo = new SmartFileInfo($rectorBacktrace[self::FILE]);
|
||||
$fileAndLine = $smartFileInfo->getRelativeFilePathFromCwd() . ':' . $rectorBacktrace['line'];
|
||||
} else {
|
||||
$fileAndLine = $rectorBacktrace[self::FILE] . ':' . $rectorBacktrace['line'];
|
||||
}
|
||||
|
||||
$message .= PHP_EOL . PHP_EOL;
|
||||
$message .= sprintf('Look at "%s"', $fileAndLine);
|
||||
}
|
||||
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $backtrace
|
||||
* @return string[]|null
|
||||
*/
|
||||
private function matchRectorBacktraceCall(array $backtrace): ?array
|
||||
{
|
||||
foreach ($backtrace as $singleBacktrace) {
|
||||
if (! isset($singleBacktrace['object'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// match a Rector class
|
||||
if (! is_a($singleBacktrace['object'], RectorInterface::class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $singleBacktrace;
|
||||
}
|
||||
|
||||
return $backtrace[1] ?? null;
|
||||
}
|
||||
}
|
|
@ -14,22 +14,13 @@ use PhpParser\Node\Identifier;
|
|||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\Core\Util\StaticNodeInstanceOf;
|
||||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeNameResolver\Error\InvalidNameNodeReporter;
|
||||
use Rector\NodeNameResolver\Regex\RegexPatternDetector;
|
||||
use Rector\NodeTypeResolver\FileSystem\CurrentFileInfoProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class NodeNameResolver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const FILE = 'file';
|
||||
|
||||
/**
|
||||
* @var NodeNameResolverInterface[]
|
||||
*/
|
||||
|
@ -40,36 +31,29 @@ final class NodeNameResolver
|
|||
*/
|
||||
private $regexPatternDetector;
|
||||
|
||||
/**
|
||||
* @var CurrentFileInfoProvider
|
||||
*/
|
||||
private $currentFileInfoProvider;
|
||||
|
||||
/**
|
||||
* @var ClassNaming
|
||||
*/
|
||||
private $classNaming;
|
||||
|
||||
/**
|
||||
* @var BetterStandardPrinter
|
||||
* @var InvalidNameNodeReporter
|
||||
*/
|
||||
private $betterStandardPrinter;
|
||||
private $invalidNameNodeReporter;
|
||||
|
||||
/**
|
||||
* @param NodeNameResolverInterface[] $nodeNameResolvers
|
||||
*/
|
||||
public function __construct(
|
||||
RegexPatternDetector $regexPatternDetector,
|
||||
BetterStandardPrinter $betterStandardPrinter,
|
||||
CurrentFileInfoProvider $currentFileInfoProvider,
|
||||
ClassNaming $classNaming,
|
||||
InvalidNameNodeReporter $invalidNameNodeReporter,
|
||||
array $nodeNameResolvers = []
|
||||
) {
|
||||
$this->regexPatternDetector = $regexPatternDetector;
|
||||
$this->nodeNameResolvers = $nodeNameResolvers;
|
||||
$this->currentFileInfoProvider = $currentFileInfoProvider;
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
$this->classNaming = $classNaming;
|
||||
$this->invalidNameNodeReporter = $invalidNameNodeReporter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +99,7 @@ final class NodeNameResolver
|
|||
return null;
|
||||
}
|
||||
|
||||
$this->reportInvalidNodeForName($node);
|
||||
$this->invalidNameNodeReporter->reportInvalidNodeForName($node);
|
||||
}
|
||||
|
||||
foreach ($this->nodeNameResolvers as $nodeNameResolver) {
|
||||
|
@ -218,65 +202,15 @@ final class NodeNameResolver
|
|||
|
||||
private function isCallOrIdentifier(Node $node): bool
|
||||
{
|
||||
return StaticNodeInstanceOf::isOneOf($node, [MethodCall::class, StaticCall::class, Identifier::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall|StaticCall $node
|
||||
*/
|
||||
private function reportInvalidNodeForName(Node $node): void
|
||||
{
|
||||
$message = sprintf('Pick more specific node than "%s", e.g. "$node->name"', get_class($node));
|
||||
|
||||
$fileInfo = $this->currentFileInfoProvider->getSmartFileInfo();
|
||||
if ($fileInfo instanceof SmartFileInfo) {
|
||||
$message .= PHP_EOL . PHP_EOL;
|
||||
$message .= sprintf(
|
||||
'Caused in "%s" file on line %d on code "%s"',
|
||||
$fileInfo->getRelativeFilePathFromCwd(),
|
||||
$node->getStartLine(),
|
||||
$this->betterStandardPrinter->print($node)
|
||||
);
|
||||
if ($node instanceof MethodCall) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace();
|
||||
$rectorBacktrace = $this->matchRectorBacktraceCall($backtrace);
|
||||
|
||||
if ($rectorBacktrace) {
|
||||
// issues to find the file in prefixed
|
||||
if (file_exists($rectorBacktrace[self::FILE])) {
|
||||
$fileInfo = new SmartFileInfo($rectorBacktrace[self::FILE]);
|
||||
$fileAndLine = $fileInfo->getRelativeFilePathFromCwd() . ':' . $rectorBacktrace['line'];
|
||||
} else {
|
||||
$fileAndLine = $rectorBacktrace[self::FILE] . ':' . $rectorBacktrace['line'];
|
||||
}
|
||||
|
||||
$message .= PHP_EOL . PHP_EOL;
|
||||
$message .= sprintf('Look at "%s"', $fileAndLine);
|
||||
if ($node instanceof StaticCall) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $backtrace
|
||||
*/
|
||||
private function matchRectorBacktraceCall(array $backtrace): ?array
|
||||
{
|
||||
foreach ($backtrace as $singleBacktrace) {
|
||||
if (! isset($singleBacktrace['object'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// match a Rector class
|
||||
if (! is_a($singleBacktrace['object'], RectorInterface::class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $singleBacktrace;
|
||||
}
|
||||
|
||||
return $backtrace[1] ?? null;
|
||||
return $node instanceof Identifier;
|
||||
}
|
||||
|
||||
private function isSingleName(Node $node, string $name): bool
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\NodeTypeResolver\FileSystem;
|
||||
|
||||
use PhpParser\Node;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class CurrentFileInfoProvider
|
||||
{
|
||||
/**
|
||||
* @var Node[]
|
||||
*/
|
||||
private $currentStmts = [];
|
||||
|
||||
/**
|
||||
* @var SmartFileInfo|null
|
||||
*/
|
||||
private $smartFileInfo;
|
||||
|
||||
public function setCurrentFileInfo(SmartFileInfo $smartFileInfo): void
|
||||
{
|
||||
$this->smartFileInfo = $smartFileInfo;
|
||||
}
|
||||
|
||||
public function getSmartFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return $this->smartFileInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $stmts
|
||||
*/
|
||||
public function setCurrentStmts(array $stmts): void
|
||||
{
|
||||
$this->currentStmts = $stmts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node[]
|
||||
*/
|
||||
public function getCurrentStmts(): array
|
||||
{
|
||||
return $this->currentStmts;
|
||||
}
|
||||
}
|
|
@ -4,9 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\NodeTypeResolver\Node;
|
||||
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class AttributeKey
|
||||
|
@ -19,7 +16,7 @@ final class AttributeKey
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const SCOPE = Scope::class;
|
||||
public const SCOPE = 'scope';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -34,7 +31,7 @@ final class AttributeKey
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CLASS_NODE = ClassLike::class;
|
||||
public const CLASS_NODE = 'class_node';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -110,6 +107,7 @@ final class AttributeKey
|
|||
public const CURRENT_STATEMENT = 'currentExpression';
|
||||
|
||||
/**
|
||||
* @deprecated Use File object instead, e.g. via CurrentFileProvider
|
||||
* @var string
|
||||
*/
|
||||
public const FILE_INFO = SmartFileInfo::class;
|
||||
|
@ -152,7 +150,7 @@ final class AttributeKey
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PHP_DOC_INFO = PhpDocInfo::class;
|
||||
public const PHP_DOC_INFO = 'php_doc_info';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor\CloningVisitor;
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
use PhpParser\NodeVisitor\NodeConnectingVisitor;
|
||||
use Rector\NodeCollector\NodeVisitor\NodeCollectorNodeVisitor;
|
||||
use Rector\NodeTypeResolver\NodeVisitor\FileInfoNodeVisitor;
|
||||
use Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamArgPositionNodeVisitor;
|
||||
use Rector\NodeTypeResolver\NodeVisitor\FunctionMethodAndClassNodeVisitor;
|
||||
use Rector\NodeTypeResolver\NodeVisitor\NamespaceNodeVisitor;
|
||||
|
@ -46,11 +44,6 @@ final class NodeScopeAndMetadataDecorator
|
|||
*/
|
||||
private $statementNodeVisitor;
|
||||
|
||||
/**
|
||||
* @var FileInfoNodeVisitor
|
||||
*/
|
||||
private $fileInfoNodeVisitor;
|
||||
|
||||
/**
|
||||
* @var NodeCollectorNodeVisitor
|
||||
*/
|
||||
|
@ -68,7 +61,6 @@ final class NodeScopeAndMetadataDecorator
|
|||
|
||||
public function __construct(
|
||||
CloningVisitor $cloningVisitor,
|
||||
FileInfoNodeVisitor $fileInfoNodeVisitor,
|
||||
FunctionMethodAndClassNodeVisitor $functionMethodAndClassNodeVisitor,
|
||||
NamespaceNodeVisitor $namespaceNodeVisitor,
|
||||
NodeCollectorNodeVisitor $nodeCollectorNodeVisitor,
|
||||
|
@ -82,15 +74,14 @@ final class NodeScopeAndMetadataDecorator
|
|||
$this->functionMethodAndClassNodeVisitor = $functionMethodAndClassNodeVisitor;
|
||||
$this->namespaceNodeVisitor = $namespaceNodeVisitor;
|
||||
$this->statementNodeVisitor = $statementNodeVisitor;
|
||||
$this->fileInfoNodeVisitor = $fileInfoNodeVisitor;
|
||||
$this->nodeCollectorNodeVisitor = $nodeCollectorNodeVisitor;
|
||||
$this->nodeConnectingVisitor = $nodeConnectingVisitor;
|
||||
$this->functionLikeParamArgPositionNodeVisitor = $functionLikeParamArgPositionNodeVisitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
* @return Node[]
|
||||
* @param Stmt[] $nodes
|
||||
* @return Stmt[]
|
||||
*/
|
||||
public function decorateNodesFromFile(array $nodes, SmartFileInfo $smartFileInfo): array
|
||||
{
|
||||
|
@ -128,7 +119,6 @@ final class NodeScopeAndMetadataDecorator
|
|||
// this split is needed, so nodes have names, classes and namespaces
|
||||
$nodeTraverser = new NodeTraverser();
|
||||
$nodeTraverser->addVisitor($this->statementNodeVisitor);
|
||||
$nodeTraverser->addVisitor($this->fileInfoNodeVisitor);
|
||||
$nodeTraverser->addVisitor($this->nodeCollectorNodeVisitor);
|
||||
|
||||
return $nodeTraverser->traverse($nodes);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\NodeTypeResolver\NodeVisitor;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
use Rector\NodeTypeResolver\FileSystem\CurrentFileInfoProvider;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
final class FileInfoNodeVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
/**
|
||||
* @var CurrentFileInfoProvider
|
||||
*/
|
||||
private $currentFileInfoProvider;
|
||||
|
||||
public function __construct(CurrentFileInfoProvider $currentFileInfoProvider)
|
||||
{
|
||||
$this->currentFileInfoProvider = $currentFileInfoProvider;
|
||||
}
|
||||
|
||||
public function enterNode(Node $node): ?Node
|
||||
{
|
||||
$node->setAttribute(AttributeKey::FILE_INFO, $this->currentFileInfoProvider->getSmartFileInfo());
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
|
@ -111,7 +110,7 @@ final class ArrayTypeMapper implements TypeMapperInterface
|
|||
return new Name('array');
|
||||
}
|
||||
|
||||
private function createArrayTypeNodeFromUnionType(UnionType $unionType): ArrayTypeNode
|
||||
private function createArrayTypeNodeFromUnionType(UnionType $unionType): SpacingAwareArrayTypeNode
|
||||
{
|
||||
$unionedArrayType = [];
|
||||
foreach ($unionType->getTypes() as $unionedType) {
|
||||
|
|
|
@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\PostRector\Application;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Logging\CurrentRectorProvider;
|
||||
use Rector\NodeTypeResolver\FileSystem\CurrentFileInfoProvider;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\PostRector\Contract\Rector\PostRectorInterface;
|
||||
use Symplify\Skipper\Skipper\Skipper;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class PostFileProcessor
|
||||
{
|
||||
|
@ -25,34 +25,34 @@ final class PostFileProcessor
|
|||
*/
|
||||
private $skipper;
|
||||
|
||||
/**
|
||||
* @var CurrentFileInfoProvider
|
||||
*/
|
||||
private $currentFileInfoProvider;
|
||||
|
||||
/**
|
||||
* @var CurrentRectorProvider
|
||||
*/
|
||||
private $currentRectorProvider;
|
||||
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
/**
|
||||
* @param PostRectorInterface[] $postRectors
|
||||
*/
|
||||
public function __construct(
|
||||
Skipper $skipper,
|
||||
CurrentFileInfoProvider $currentFileInfoProvider,
|
||||
CurrentFileProvider $currentFileProvider,
|
||||
CurrentRectorProvider $currentRectorProvider,
|
||||
array $postRectors
|
||||
) {
|
||||
$this->postRectors = $this->sortByPriority($postRectors);
|
||||
$this->skipper = $skipper;
|
||||
$this->currentFileInfoProvider = $currentFileInfoProvider;
|
||||
$this->currentRectorProvider = $currentRectorProvider;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
* @return Node[]
|
||||
* @param Stmt[] $nodes
|
||||
* @return Stmt[]
|
||||
*/
|
||||
public function traverse(array $nodes): array
|
||||
{
|
||||
|
@ -94,11 +94,12 @@ final class PostFileProcessor
|
|||
|
||||
private function shouldSkipPostRector(PostRectorInterface $postRector): bool
|
||||
{
|
||||
$smartFileInfo = $this->currentFileInfoProvider->getSmartFileInfo();
|
||||
if (! $smartFileInfo instanceof SmartFileInfo) {
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
if (! $file instanceof File) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
return $this->skipper->shouldSkipElementAndFileInfo($postRector, $smartFileInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use Rector\ChangesReporting\Collector\AffectedFilesCollector;
|
|||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\NodeRemoval\BreakingRemovalGuard;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
|
||||
|
@ -50,16 +50,23 @@ final class NodesToRemoveCollector implements NodeCollectorInterface
|
|||
*/
|
||||
private $nodeComparator;
|
||||
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
public function __construct(
|
||||
AffectedFilesCollector $affectedFilesCollector,
|
||||
BreakingRemovalGuard $breakingRemovalGuard,
|
||||
BetterNodeFinder $betterNodeFinder,
|
||||
NodeComparator $nodeComparator
|
||||
NodeComparator $nodeComparator,
|
||||
CurrentFileProvider $currentFileProvider
|
||||
) {
|
||||
$this->affectedFilesCollector = $affectedFilesCollector;
|
||||
$this->breakingRemovalGuard = $breakingRemovalGuard;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
|
||||
public function addNodeToRemove(Node $node): void
|
||||
|
@ -80,10 +87,11 @@ final class NodesToRemoveCollector implements NodeCollectorInterface
|
|||
$this->breakingRemovalGuard->ensureNodeCanBeRemove($node);
|
||||
}
|
||||
|
||||
/** @var SmartFileInfo|null $fileInfo */
|
||||
$fileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if ($fileInfo !== null) {
|
||||
$this->affectedFilesCollector->addFile(new File($fileInfo, $fileInfo->getContents()));
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
|
||||
// /** @var SmartFileInfo|null $fileInfo */
|
||||
if ($file !== null) {
|
||||
$this->affectedFilesCollector->addFile($file);
|
||||
}
|
||||
|
||||
/** @var Stmt $node */
|
||||
|
|
|
@ -7,7 +7,8 @@ namespace Rector\PostRector\Collector;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\NodeTypeResolver\FileSystem\CurrentFileInfoProvider;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
|
@ -26,19 +27,19 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
*/
|
||||
private $functionUseImportTypesInFilePath = [];
|
||||
|
||||
/**
|
||||
* @var CurrentFileInfoProvider
|
||||
*/
|
||||
private $currentFileInfoProvider;
|
||||
|
||||
/**
|
||||
* @var FullyQualifiedObjectType[][]|AliasedObjectType[][]
|
||||
*/
|
||||
private $useImportTypesInFilePath = [];
|
||||
|
||||
public function __construct(CurrentFileInfoProvider $currentFileInfoProvider)
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
public function __construct(CurrentFileProvider $currentFileProvider)
|
||||
{
|
||||
$this->currentFileInfoProvider = $currentFileInfoProvider;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
|
@ -51,37 +52,30 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
*/
|
||||
public function addUseImport(Node $positionNode, ObjectType $objectType): void
|
||||
{
|
||||
/** @var SmartFileInfo|null $fileInfo */
|
||||
$fileInfo = $positionNode->getAttribute(AttributeKey::FILE_INFO);
|
||||
if (! $fileInfo instanceof SmartFileInfo) {
|
||||
// fallback for freshly created Name nodes
|
||||
$fileInfo = $this->currentFileInfoProvider->getSmartFileInfo();
|
||||
if (! $fileInfo instanceof SmartFileInfo) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
$this->useImportTypesInFilePath[$fileInfo->getRealPath()][] = $objectType;
|
||||
$this->useImportTypesInFilePath[$smartFileInfo->getRealPath()][] = $objectType;
|
||||
}
|
||||
|
||||
public function addFunctionUseImport(Node $node, FullyQualifiedObjectType $fullyQualifiedObjectType): void
|
||||
{
|
||||
$fileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if (! $fileInfo instanceof SmartFileInfo) {
|
||||
return;
|
||||
}
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
$this->functionUseImportTypesInFilePath[$fileInfo->getRealPath()][] = $fullyQualifiedObjectType;
|
||||
$this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()][] = $fullyQualifiedObjectType;
|
||||
}
|
||||
|
||||
public function removeShortUse(Node $node, string $shortUse): void
|
||||
{
|
||||
$fileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if (! $fileInfo instanceof SmartFileInfo) {
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
if (! $file instanceof File) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->removedShortUsesInFilePath[$fileInfo->getRealPath()][] = $shortUse;
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
$this->removedShortUsesInFilePath[$smartFileInfo->getRealPath()][] = $shortUse;
|
||||
}
|
||||
|
||||
public function clear(SmartFileInfo $smartFileInfo): void
|
||||
|
@ -95,7 +89,7 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
*/
|
||||
public function getUseImportTypesByNode(Node $node): array
|
||||
{
|
||||
$filePath = $this->getRealPathFromNode($node);
|
||||
$filePath = $this->getRealPathFromNode();
|
||||
|
||||
$objectTypes = $this->useImportTypesInFilePath[$filePath] ?? [];
|
||||
|
||||
|
@ -129,7 +123,7 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
|
||||
public function isShortImported(Node $node, FullyQualifiedObjectType $fullyQualifiedObjectType): bool
|
||||
{
|
||||
$filePath = $this->getRealPathFromNode($node);
|
||||
$filePath = $this->getRealPathFromNode();
|
||||
if ($filePath === null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -152,7 +146,7 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
|
||||
public function isImportShortable(Node $node, FullyQualifiedObjectType $fullyQualifiedObjectType): bool
|
||||
{
|
||||
$filePath = $this->getRealPathFromNode($node);
|
||||
$filePath = $this->getRealPathFromNode();
|
||||
|
||||
$fileUseImportTypes = $this->useImportTypesInFilePath[$filePath] ?? [];
|
||||
|
||||
|
@ -196,19 +190,15 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
|
|||
return $this->removedShortUsesInFilePath[$smartFileInfo->getRealPath()] ?? [];
|
||||
}
|
||||
|
||||
private function getRealPathFromNode(Node $node): ?string
|
||||
private function getRealPathFromNode(): ?string
|
||||
{
|
||||
/** @var SmartFileInfo|null $fileInfo */
|
||||
$fileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if ($fileInfo !== null) {
|
||||
return $fileInfo->getRealPath();
|
||||
}
|
||||
|
||||
$smartFileInfo = $this->currentFileInfoProvider->getSmartFileInfo();
|
||||
if (! $smartFileInfo instanceof SmartFileInfo) {
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
if (! $file instanceof File) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
return $smartFileInfo->getRealPath();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,20 +5,18 @@ declare(strict_types=1);
|
|||
namespace Rector\PostRector\Rector;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\CodingStyle\Application\UseImportsAdder;
|
||||
use Rector\CodingStyle\Application\UseImportsRemover;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\PostRector\Collector\UseNodesToAddCollector;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class UseAddingPostRector extends AbstractPostRector
|
||||
{
|
||||
|
@ -47,18 +45,25 @@ final class UseAddingPostRector extends AbstractPostRector
|
|||
*/
|
||||
private $useNodesToAddCollector;
|
||||
|
||||
/**
|
||||
* @var CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
|
||||
public function __construct(
|
||||
BetterNodeFinder $betterNodeFinder,
|
||||
TypeFactory $typeFactory,
|
||||
UseImportsAdder $useImportsAdder,
|
||||
UseImportsRemover $useImportsRemover,
|
||||
UseNodesToAddCollector $useNodesToAddCollector
|
||||
UseNodesToAddCollector $useNodesToAddCollector,
|
||||
CurrentFileProvider $currentFileProvider
|
||||
) {
|
||||
$this->useImportsAdder = $useImportsAdder;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->useImportsRemover = $useImportsRemover;
|
||||
$this->typeFactory = $typeFactory;
|
||||
$this->useNodesToAddCollector = $useNodesToAddCollector;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,10 +77,8 @@ final class UseAddingPostRector extends AbstractPostRector
|
|||
return $nodes;
|
||||
}
|
||||
|
||||
$smartFileInfo = $this->getSmartFileInfo($nodes);
|
||||
if (! $smartFileInfo instanceof SmartFileInfo) {
|
||||
return $nodes;
|
||||
}
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
|
||||
$useImportTypes = $this->useNodesToAddCollector->getObjectImportsByFileInfo($smartFileInfo);
|
||||
$functionUseImportTypes = $this->useNodesToAddCollector->getFunctionImportsByFileInfo($smartFileInfo);
|
||||
|
@ -149,22 +152,6 @@ CODE_SAMPLE
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
*/
|
||||
private function getSmartFileInfo(array $nodes): ?SmartFileInfo
|
||||
{
|
||||
foreach ($nodes as $node) {
|
||||
/** @var SmartFileInfo|null $smartFileInfo */
|
||||
$smartFileInfo = $node->getAttribute(AttributeKey::FILE_INFO);
|
||||
if ($smartFileInfo !== null) {
|
||||
return $smartFileInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents
|
||||
* @param FullyQualifiedObjectType[] $useImportTypes
|
||||
|
|
|
@ -104,11 +104,10 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase implements
|
|||
);
|
||||
|
||||
$inputFileInfo = $inputFileInfoAndExpectedFileInfo->getInputFileInfo();
|
||||
$this->originalTempFileInfo = $inputFileInfo;
|
||||
|
||||
$expectedFileInfo = $inputFileInfoAndExpectedFileInfo->getExpectedFileInfo();
|
||||
$this->doTestFileMatchesExpectedContent($inputFileInfo, $expectedFileInfo, $fixtureFileInfo);
|
||||
|
||||
$this->originalTempFileInfo = $inputFileInfo;
|
||||
}
|
||||
|
||||
protected function getFixtureTempDirectory(): string
|
||||
|
|
|
@ -517,3 +517,12 @@ parameters:
|
|||
message: '#Unreachable statement \- code above always terminates#'
|
||||
paths:
|
||||
- src/Application/FileProcessor/PhpFileProcessor.php
|
||||
|
||||
-
|
||||
message: '#Property with protected modifier is not allowed\. Use interface contract method instead#'
|
||||
paths:
|
||||
- src/Rector/AbstractRector.php
|
||||
|
||||
- '#Cannot call method getSmartFileInfo\(\) on Rector\\Core\\ValueObject\\Application\\File\|null#'
|
||||
- '#Class with base "Parser" name is already used in "Hoa\\Compiler\\Llk\\Parser", "Rector\\Core\\PhpParser\\Parser\\Parser"\. Use unique name to make classes easy to recognize#'
|
||||
- '#Parameter \#1 \$file of method Rector\\CodingStyle\\ClassNameImport\\ShortNameResolver\:\:resolveForNode\(\) expects Rector\\Core\\ValueObject\\Application\\File, Rector\\Core\\ValueObject\\Application\\File\|null given#'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveEntitiesToEntityDirectoryRector\Source\Entity;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveEntitiesToEntityDirectoryRector\Source\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveEntitiesToEntityDirectoryRector;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveEntitiesToEntityDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveEntitiesToEntityDirectoryRector\Source\Controller;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveEntitiesToEntityDirectoryRector\Source\Controller;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveEntitiesToEntityDirectoryRector;
|
||||
use Rector\Autodiscovery\Rector\Class_\MoveEntitiesToEntityDirectoryRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(MoveEntitiesToEntityDirectoryRector::class);
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Command;
|
||||
|
||||
final class BananaCommand
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return new \Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Orange();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class MissPlacedController
|
||||
{
|
||||
public function getSelf()
|
||||
{
|
||||
return new \Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\MissPlacedController();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested;
|
||||
|
||||
abstract class AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested;
|
||||
|
||||
abstract class AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper;
|
||||
final class UserMapper extends \Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseWithSpaceMapper;
|
||||
final class UserWithSpaceMapper extends \Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Repository;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
services:
|
||||
Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseMapper: null
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Command;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Command;
|
||||
|
||||
final class MissPlacedController
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class BananaCommand
|
||||
{
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested;
|
||||
|
||||
abstract class AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested;
|
||||
|
||||
abstract class AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class Orange
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper;
|
||||
|
||||
final class UserMapper extends AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseWithSpaceMapper;
|
||||
|
||||
final class UserWithSpaceMapper extends AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\SkipAlreadyMoved\Source\Mapper;
|
||||
|
||||
final class SkipCorrectMapper
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Repository;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
services:
|
||||
Rector\Tests\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper: null
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
use Rector\Autodiscovery\Rector\Class_\MoveServicesBySuffixToDirectoryRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
|
||||
final class MeSearch
|
||||
{
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
|
||||
class PrimitiveValueObject
|
||||
{
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
final class SomeName implements \Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface
|
||||
{
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\Command;
|
||||
|
||||
final class MeSearch
|
||||
{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\Command;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
|
||||
final class SomeName implements ObviousValueObjectInterface
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source;
|
||||
|
||||
interface ObviousValueObjectInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\Repository;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\Repository;
|
||||
|
||||
class PrimitiveValueObject
|
||||
{
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\Utils;
|
||||
|
||||
final class SomeSuffixedTest
|
||||
{
|
||||
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
use Rector\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity;
|
||||
|
||||
final class SameClassImplementEntity implements \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
public function __construct(\Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface $random)
|
||||
{
|
||||
}
|
||||
|
||||
public function returnAnother(): \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity;
|
||||
|
||||
class RandomInterfaceUseCaseInTheSameNamespace
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
*/
|
||||
public $random;
|
||||
|
||||
public function create(): \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract;
|
||||
|
||||
interface RandomInterface
|
||||
{
|
||||
public function returnAnother(): \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface;
|
||||
|
||||
class RandomInterfaceUseCase
|
||||
{
|
||||
public \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface $random;
|
||||
|
||||
public function create(): \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\Foo;
|
||||
|
||||
interface KeepThisSomeInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract;
|
||||
|
||||
interface KeepThisSomeInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Control;
|
||||
|
||||
interface ControlFactory
|
||||
{
|
||||
public function create(): SomeControl;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Control;
|
||||
|
||||
use Nette\Application\UI\Control;
|
||||
|
||||
final class SomeControl extends Control
|
||||
{
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Control;
|
||||
|
||||
use Nette\Application\UI\Form;
|
||||
|
||||
final class SomeForm extends Form
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity;
|
||||
|
||||
interface RandomInterface
|
||||
{
|
||||
public function returnAnother(): RandomInterface;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity\RandomInterface;
|
||||
|
||||
class RandomInterfaceUseCase
|
||||
{
|
||||
/**
|
||||
* @var RandomInterface
|
||||
*/
|
||||
public $random;
|
||||
|
||||
public function create(): RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\ValueObject;
|
||||
|
||||
final class SameClassImplementEntity implements \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity\RandomInterface
|
||||
{
|
||||
public function __construct(\Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity\RandomInterface $random)
|
||||
{
|
||||
}
|
||||
public function returnAnother(): \Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Command;
|
||||
|
||||
final class BananaCommand
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return new \Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Orange();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class MissPlacedController
|
||||
{
|
||||
public function getSelf()
|
||||
{
|
||||
return new \Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\MissPlacedController();
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested;
|
||||
|
||||
abstract class AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested;
|
||||
|
||||
abstract class AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper;
|
||||
final class UserMapper extends \Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseWithSpaceMapper;
|
||||
final class UserWithSpaceMapper extends \Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Repository;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
services:
|
||||
Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Mapper\Nested\AbstractBaseMapper: null
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested;
|
||||
|
||||
abstract class AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested;
|
||||
|
||||
abstract class AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class Orange
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper;
|
||||
|
||||
final class UserMapper extends AbstractBaseMapper
|
||||
{
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Entity;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseWithSpaceMapper;
|
||||
|
||||
final class UserWithSpaceMapper extends AbstractBaseWithSpaceMapper
|
||||
{
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\SkipAlreadyMoved\Source\Mapper;
|
||||
|
||||
final class SkipCorrectMapper
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Repository;
|
||||
|
||||
class AppleRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
services:
|
||||
Rector\Tests\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector\Source\Controller\Nested\AbstractBaseMapper: null
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
|
||||
final class MeSearch
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ValueObject;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
final class SomeName implements \Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface
|
||||
{
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\Command;
|
||||
|
||||
final class MeSearch
|
||||
{
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\Command;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
|
||||
final class SomeName implements ObviousValueObjectInterface
|
||||
{
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source;
|
||||
|
||||
interface ObviousValueObjectInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\Utils;
|
||||
|
||||
final class SomeSuffixedTest
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity;
|
||||
|
||||
final class SameClassImplementEntity implements \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
public function __construct(\Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface $random)
|
||||
{
|
||||
}
|
||||
|
||||
public function returnAnother(): \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Entity;
|
||||
|
||||
class RandomInterfaceUseCaseInTheSameNamespace
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
*/
|
||||
public $random;
|
||||
|
||||
public function create(): \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract;
|
||||
|
||||
interface RandomInterface
|
||||
{
|
||||
public function returnAnother(): \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source;
|
||||
|
||||
use Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface;
|
||||
|
||||
class RandomInterfaceUseCase
|
||||
{
|
||||
public \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface $random;
|
||||
|
||||
public function create(): \Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\RandomInterface
|
||||
{
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\FileNode\MoveInterfacesToContractNamespaceDirectoryRector;
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract\Foo;
|
||||
|
||||
interface KeepThisSomeInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Autodiscovery\Rector\Interface_\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract;
|
||||
|
||||
interface KeepThisSomeInterface
|
||||
{
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user