mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-18 23:05:25 +01:00
add FQNize same-namespace test
This commit is contained in:
parent
57bc309d5a
commit
abf9ced755
@ -83,8 +83,6 @@ final class FileMover
|
||||
}
|
||||
}
|
||||
|
||||
// @todo: nodes must be sometimes FQNized
|
||||
|
||||
// 3. return changed nodes and new file destination
|
||||
$newFileDestination = $this->fileRelocationResolver->createNewFileDestination(
|
||||
$smartFileInfo,
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace Rector\Autodiscovery\Tests\Rector\FileSystem\MoveServicesBySuffixToDirectoryRector\Source\Command;
|
||||
|
||||
final class BananaCommand
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return new \Rector\Autodiscovery\Tests\Rector\FileSystem\MoveServicesBySuffixToDirectoryRector\Source\Controller\Orange();
|
||||
}
|
||||
}
|
@ -35,13 +35,19 @@ final class MoveServicesBySuffixToDirectoryRectorTest extends AbstractFileSystem
|
||||
__DIR__ . '/Source/Fixture/Repository/AppleRepository.php',
|
||||
__DIR__ . '/Fixture/ExpectedAppleRepository.php',
|
||||
];
|
||||
|
||||
yield 'prefix_same_namespace' => [
|
||||
__DIR__ . '/Source/Controller/BananaCommand.php',
|
||||
__DIR__ . '/Source/Fixture/Command/BananaCommand.php',
|
||||
__DIR__ . '/Fixture/Command/ExpectedBananaCommand.php',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
{
|
||||
return [
|
||||
MoveServicesBySuffixToDirectoryRector::class => [
|
||||
'$groupNamesBySuffix' => ['Repository'],
|
||||
'$groupNamesBySuffix' => ['Repository', 'Command'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Autodiscovery\Tests\Rector\FileSystem\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class BananaCommand
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return new Orange();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Autodiscovery\Tests\Rector\FileSystem\MoveServicesBySuffixToDirectoryRector\Source\Controller;
|
||||
|
||||
final class Orange
|
||||
{
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ use PhpParser\Node\Scalar\EncapsedStringPart;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Declare_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use PhpParser\Node\Stmt\TraitUse;
|
||||
@ -225,6 +226,16 @@ final class BetterStandardPrinter extends Standard
|
||||
return parent::pStmt_Class($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It remove all spaces extra to parent
|
||||
*/
|
||||
protected function pStmt_Declare(Declare_ $declare): string
|
||||
{
|
||||
$declareString = parent::pStmt_Declare($declare);
|
||||
|
||||
return Strings::replace($declareString, '#\s+#');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
declare (strict_types=1);
|
||||
declare(strict_types=1);
|
||||
namespace NettePostfixedToUniqueAutoload\Utils;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user