mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 20:53:31 +00:00
skip already correct group
This commit is contained in:
parent
7a85d8596e
commit
daaf2143d8
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\Autodiscovery\FileMover;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
|
@ -60,6 +61,11 @@ final class FileMover
|
|||
|
||||
$currentClassName = $currentNamespace->name->toString() . '\\' . $smartFileInfo->getBasenameWithoutSuffix();
|
||||
|
||||
// is already in the right group
|
||||
if (Strings::endsWith((string) $currentNamespace->name, '\\' . $desiredGroupName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// change namespace to new one
|
||||
$newNamespaceName = $this->createNewNamespaceName($desiredGroupName, $currentNamespace);
|
||||
$newClassName = $this->createNewClassName($smartFileInfo, $newNamespaceName);
|
||||
|
|
|
@ -42,6 +42,14 @@ final class MoveInterfacesToContractNamespaceDirectoryRectorTest extends Abstrac
|
|||
$this->getFixtureTempDirectory() . '/Source/Control/FormFactory.php',
|
||||
__DIR__ . '/Source/Control/FormFactory.php',
|
||||
];
|
||||
|
||||
// skip already in correct location
|
||||
yield [
|
||||
__DIR__ . '/Source/Contract/KeepThisSomeInterface.php',
|
||||
$this->getFixtureTempDirectory() . '/Source/Contract/KeepThisSomeInterface.php',
|
||||
// no change
|
||||
__DIR__ . '/Source/Contract/KeepThisSomeInterface.php',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Autodiscovery\Tests\Rector\FileSystem\MoveEntitiesToEntityDirectoryRector\Source\Contract;
|
||||
|
||||
interface RandomInterface
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Autodiscovery\Tests\Rector\FileSystem\MoveInterfacesToContractNamespaceDirectoryRector\Source\Contract;
|
||||
|
||||
interface KeepThisSomeInterface
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user