move PreferThisOrSelfMethodCall to CodingStyle

This commit is contained in:
Tomas Votruba 2019-09-23 18:09:22 +02:00
parent 24ebc66747
commit 7d9c389748
13 changed files with 72 additions and 64 deletions

View File

@ -4242,13 +4242,13 @@ Changes pow(val, val2) to ** (exp) parameter
### `PreferThisOrSelfMethodCallRector`
- class: `Rector\Php\Rector\MethodCall\PreferThisOrSelfMethodCallRector`
- class: `Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector`
Changes $this->... to self:: or vise versa for specific types
```yaml
services:
Rector\Php\Rector\MethodCall\PreferThisOrSelfMethodCallRector:
Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector:
PHPUnit\TestCase: self
```

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1);
namespace Rector\Php\Rector\MethodCall;
namespace Rector\CodingStyle\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
@ -11,7 +11,7 @@ use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* @see \Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\PreferThisOrSelfMethodCallRectorTest
* @see \Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\PreferThisOrSelfMethodCallRectorTest
*/
final class PreferThisOrSelfMethodCallRector extends AbstractRector
{

View File

@ -0,0 +1,35 @@
<?php
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
class ToSelf extends AbstractTestCase
{
public function run()
{
$this->assertThis();
self::assertThis();
parent::assertThis();
}
}
?>
-----
<?php
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
class ToSelf extends AbstractTestCase
{
public function run()
{
self::assertThis();
self::assertThis();
parent::assertThis();
}
}
?>

View File

@ -1,8 +1,8 @@
<?php
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
final class ToThis extends BeLocalClass
{
@ -19,9 +19,9 @@ final class ToThis extends BeLocalClass
-----
<?php
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
final class ToThis extends BeLocalClass
{

View File

@ -1,10 +1,10 @@
<?php declare(strict_types=1);
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\Php\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class PreferThisOrSelfMethodCallRectorTest extends AbstractRectorTestCase

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source;
abstract class AbstractTestCase
{
}

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source;
class BeLocalClass
{
}

View File

@ -1,35 +0,0 @@
<?php
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
class ToSelf extends AbstractTestCase
{
public function run()
{
$this->assertThis();
self::assertThis();
parent::assertThis();
}
}
?>
-----
<?php
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Fixture;
use Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
class ToSelf extends AbstractTestCase
{
public function run()
{
self::assertThis();
self::assertThis();
parent::assertThis();
}
}
?>

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source;
abstract class AbstractTestCase
{
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Php\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source;
class BeLocalClass
{
}

View File

@ -0,0 +1,8 @@
services:
_defaults:
public: true
autowire: true
Rector\Php71\:
resource: '../src'
exclude: '../src/{Rector/**/*Rector.php}'

View File

@ -14,7 +14,7 @@ use Rector\RectorDefinition\RectorDefinition;
/**
* @see https://wiki.php.net/rfc/object-typehint
* @see https://github.com/cebe/yii2/commit/9548a212ecf6e50fcdb0e5ba6daad88019cfc544
* @see \Rector\Php\Tests\Rector\Name\ReservedObjectRector\ReservedObjectRectorTest
* @see \Rector\Php71\Tests\Rector\Name\ReservedObjectRector\ReservedObjectRectorTest
*/
final class ReservedObjectRector extends AbstractRector
{