Skip to content

Commit

Permalink
[Php55] Move GetCalledClassToSelfClassRector + GetCalledClassToStatic…
Browse files Browse the repository at this point in the history
…ClassRector from php 7.4 to 5.5 SetList (#1972)
  • Loading branch information
samsonasik authored Mar 28, 2022
1 parent 90bbd4e commit a20320d
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 70 deletions.
80 changes: 40 additions & 40 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

- [Php54](#php54) (2)

- [Php55](#php55) (3)
- [Php55](#php55) (5)

- [Php56](#php56) (2)

Expand All @@ -66,7 +66,7 @@

- [Php73](#php73) (9)

- [Php74](#php74) (16)
- [Php74](#php74) (14)

- [Php80](#php80) (17)

Expand Down Expand Up @@ -6740,6 +6740,44 @@ Change `__CLASS__` to self::class

<br>

### GetCalledClassToSelfClassRector

Change `get_called_class()` to self::class on final class

- class: [`Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector`](../rules/Php55/Rector/FuncCall/GetCalledClassToSelfClassRector.php)

```diff
final class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(self::class);
}
}
```

<br>

### GetCalledClassToStaticClassRector

Change `get_called_class()` to static::class on non-final class

- class: [`Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector`](../rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php)

```diff
class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(static::class);
}
}
```

<br>

### PregReplaceEModifierRector

The /e modifier is no longer supported, use preg_replace_callback instead
Expand Down Expand Up @@ -7837,44 +7875,6 @@ Change `filter_var()` with slash escaping to `addslashes()`

<br>

### GetCalledClassToSelfClassRector

Change `get_called_class()` to self::class on final class

- class: [`Rector\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector`](../rules/Php74/Rector/FuncCall/GetCalledClassToSelfClassRector.php)

```diff
final class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(self::class);
}
}
```

<br>

### GetCalledClassToStaticClassRector

Change `get_called_class()` to static::class on non-final class

- class: [`Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector`](../rules/Php74/Rector/FuncCall/GetCalledClassToStaticClassRector.php)

```diff
class SomeClass
{
public function callOnMe()
{
- var_dump(get_called_class());
+ var_dump(static::class);
}
}
```

<br>

### MbStrrposEncodingArgumentPositionRector

Change `mb_strrpos()` encoding argument position
Expand Down
4 changes: 4 additions & 0 deletions config/set/php55.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
declare(strict_types=1);

use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
Expand All @@ -12,4 +14,6 @@
$services->set(StringClassNameToClassConstantRector::class);
$services->set(ClassConstantToSelfClassRector::class);
$services->set(PregReplaceEModifierRector::class);
$services->set(GetCalledClassToSelfClassRector::class);
$services->set(GetCalledClassToStaticClassRector::class);
};
6 changes: 0 additions & 6 deletions config/set/php74.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector;
use Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector;
use Rector\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector;
use Rector\Php74\Rector\Function_\ReservedFnFunctionRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
Expand Down Expand Up @@ -42,10 +40,6 @@

$services->set(ExportToReflectionFunctionRector::class);

$services->set(GetCalledClassToSelfClassRector::class);

$services->set(GetCalledClassToStaticClassRector::class);

$services->set(MbStrrposEncodingArgumentPositionRector::class);

$services->set(RealToFloatTypeCastRector::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

new class {
public function callOnMe()
Expand All @@ -13,7 +13,7 @@ new class {
-----
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

new class {
public function callOnMe()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

final class Fixture
{
Expand All @@ -14,7 +14,7 @@ final class Fixture
-----
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

final class Fixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

class SkipOnNonFinalClass
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\Fixture;

trait SkipTrait
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;

use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Rector\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

class Fixture
{
Expand All @@ -14,7 +14,7 @@ class Fixture
-----
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

class Fixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

new class {
public function callOnMe()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

final class SkipOnFinalClass
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

trait SomeTrait
{
Expand All @@ -14,7 +14,7 @@ trait SomeTrait
-----
<?php

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\Fixture;

trait SomeTrait
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector;
namespace Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;

use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Php74\Rector\FuncCall;
namespace Rector\Php55\Rector\FuncCall;

use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
Expand All @@ -16,9 +16,9 @@
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet)
* @changelog https://www.php.net/ChangeLog-5.php#5.5.0
* @see https://3v4l.org/GU9dP
* @see \Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector\GetCalledClassToSelfClassRectorTest
* @see \Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\GetCalledClassToSelfClassRectorTest
*/
final class GetCalledClassToSelfClassRector extends AbstractRector implements MinPhpVersionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Php74\Rector\FuncCall;
namespace Rector\Php55\Rector\FuncCall;

use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
Expand All @@ -16,9 +16,9 @@
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet)
* @changelog https://www.php.net/ChangeLog-5.php#5.5.0
* @see https://3v4l.org/dJgXd
* @see \Rector\Tests\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector\GetCalledClassToStaticClassRectorTest
* @see \Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\GetCalledClassToStaticClassRectorTest
*/
final class GetCalledClassToStaticClassRector extends AbstractRector implements MinPhpVersionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use Rector\Php74\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand Down

0 comments on commit a20320d

Please sign in to comment.