mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 19:00:49 +00:00
add PHPUnit and PHP_CodeSniffer class rectors
This commit is contained in:
parent
041b1b5503
commit
81c17ac78e
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Rector\Deprecation;
|
||||
|
||||
/**
|
||||
* @todo split to make SOLID
|
||||
*/
|
||||
final class SetNames
|
||||
{
|
||||
/**
|
||||
|
@ -18,4 +21,14 @@ final class SetNames
|
|||
* @var string
|
||||
*/
|
||||
public const SYMFONY_EXTRA = 'SymfonyExtra';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PHPUNIT = 'PHPUnit';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PHP_CODE_SNIFER = 'PHP_CodeSniffer';
|
||||
}
|
||||
|
|
29
src/Rector/Contrib/PHPUnit/NamespaceClassRector.php
Normal file
29
src/Rector/Contrib/PHPUnit/NamespaceClassRector.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Rector\Contrib\PHPUnit;
|
||||
|
||||
use Rector\Deprecation\SetNames;
|
||||
use Rector\Rector\AbstractClassReplacerRector;
|
||||
|
||||
final class NamespaceClassRector extends AbstractClassReplacerRector
|
||||
{
|
||||
public function getSetName(): string
|
||||
{
|
||||
return SetNames::PHPUNIT;
|
||||
}
|
||||
|
||||
public function sinceVersion(): float
|
||||
{
|
||||
return 6.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getOldToNewClasses(): array
|
||||
{
|
||||
return [
|
||||
'PHPUnit_Framework_TestCase' => 'PHPUnit\Framework\TestCase',
|
||||
];
|
||||
}
|
||||
}
|
29
src/Rector/Contrib/PHP_CodeSniffer/NamespaceClassRector.php
Normal file
29
src/Rector/Contrib/PHP_CodeSniffer/NamespaceClassRector.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Rector\Contrib\PHP_CodeSniffer;
|
||||
|
||||
use Rector\Deprecation\SetNames;
|
||||
use Rector\Rector\AbstractClassReplacerRector;
|
||||
|
||||
final class NamespaceClassRector extends AbstractClassReplacerRector
|
||||
{
|
||||
public function getSetName(): string
|
||||
{
|
||||
return SetNames::PHP_CODE_SNIFER;
|
||||
}
|
||||
|
||||
public function sinceVersion(): float
|
||||
{
|
||||
return 3.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getOldToNewClasses(): array
|
||||
{
|
||||
return [
|
||||
'PHP_CodeSniffer_Sniffs_Sniff' => 'PHP_CodeSniffer\Sniffs\Sniff',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php declare (strict_types=1);
|
||||
|
||||
class MyTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
}
|
25
tests/Rector/Contrib/PHPUnit/NamespaceClassRector/Test.php
Normal file
25
tests/Rector/Contrib/PHPUnit/NamespaceClassRector/Test.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\Contrib\PHPUnit\NamespaceClassRector;
|
||||
|
||||
use Rector\Rector\Contrib\PHPUnit\NamespaceClassRector;
|
||||
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 [NamespaceClassRector::class];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php declare (strict_types=1);
|
||||
|
||||
class MyTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php declare (strict_types=1);
|
||||
|
||||
class Sniff implements \PHP_CodeSniffer\Sniffs\Sniff
|
||||
{
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\Contrib\PHP_CodeSniffer\NamespaceClassRector;
|
||||
|
||||
use Rector\Rector\Contrib\PHP_CodeSniffer\NamespaceClassRector;
|
||||
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 [NamespaceClassRector::class];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php declare (strict_types=1);
|
||||
|
||||
class Sniff implements PHP_CodeSniffer_Sniffs_Sniff
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user