[Nette] add NetteConfiguratorRector

This commit is contained in:
TomasVotruba 2017-09-06 23:29:05 +02:00
parent 1ec4797bed
commit 36d9c5f5e0
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace Rector\Rector\Contrib\Nette;
use Rector\Deprecation\SetNames;
use Rector\Rector\AbstractClassReplacerRector;
final class NetteConfiguratorRector extends AbstractClassReplacerRector
{
public function getSetName(): string
{
return SetNames::NETTE;
}
public function sinceVersion(): float
{
return 2.1;
}
/**
* @return string[]
*/
protected function getOldToNewClasses(): array
{
return [
'Nette\Config\Configurator' => 'Nette\Configurator'
];
}
}

View File

@ -0,0 +1,3 @@
<?php declare (strict_types=1);
$configurator = new \Nette\Configurator;

View File

@ -0,0 +1,25 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Contrib\Nette\NetteConfiguratorRector;
use Rector\Rector\Contrib\Nette\NetteConfiguratorRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class Test extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFileMatchesExpectedContent(
__DIR__ . '/Wrong/wrong.php.inc',
__DIR__ . '/Correct/correct.php.inc'
);
}
/**
* @return string[]
*/
protected function getRectorClasses(): array
{
return [NetteConfiguratorRector::class];
}
}

View File

@ -0,0 +1,3 @@
<?php declare (strict_types=1);
$configurator = new Nette\Config\Configurator;