-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp80] Add DowngradeNamedArgumentRector (#133)
Co-authored-by: kaizen-ci <info@kaizen-ci.org>
- Loading branch information
1 parent
42ca188
commit 02f9524
Showing
15 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...adePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector/Fixture/use_attribute.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector\Fixture; | ||
|
||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] | ||
class AutoconfigureTag | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector\Fixture; | ||
|
||
/** | ||
* @Attribute | ||
*/ | ||
class AutoconfigureTag | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...Php80/Rector/MethodCall/DowngradeNamedArgumentRector/DowngradeNamedArgumentRectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class DowngradeNamedArgumentRectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
* @requires PHP 8.0 | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...sts/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/fixture.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class Fixture | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute(a: [[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class Fixture | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute([[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> |
35 changes: 35 additions & 0 deletions
35
...ts/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/fixture2.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class Fixture2 | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute(b: [[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class Fixture2 | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute(null, [[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> |
37 changes: 37 additions & 0 deletions
37
.../DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/flip_order.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class FlipOrder | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
var_dump($b); | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute(b: [[$name ?? 0 => $attributes]], a: []); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
class FlipOrder | ||
{ | ||
private function execute(?array $a = null, ?array $b = null) | ||
{ | ||
var_dump($b); | ||
} | ||
|
||
public function run(string $name = null, array $attributes = []) | ||
{ | ||
$this->execute([], [[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/skip_no_arg.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo; | ||
|
||
class SkipNoArg extends Foo | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
parent::__construct(); | ||
} | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...adePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/skip_no_named_arg.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo; | ||
|
||
class SkipNoNamedArg extends Foo | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
parent::__construct([], []); | ||
} | ||
} | ||
|
||
?> |
31 changes: 31 additions & 0 deletions
31
...DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Fixture/static_call.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo; | ||
|
||
class StaticCall extends Foo | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
parent::__construct(a: [[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Fixture; | ||
|
||
use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo; | ||
|
||
class StaticCall extends Foo | ||
{ | ||
public function __construct(string $name = null, array $attributes = []) | ||
{ | ||
parent::__construct([[$name ?? 0 => $attributes]]); | ||
} | ||
} | ||
|
||
?> |
14 changes: 14 additions & 0 deletions
14
rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/Source/Foo.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source; | ||
|
||
class Foo | ||
{ | ||
public function __construct( | ||
public ?array $a = null, | ||
public ?array $b = null | ||
) { | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector/config/configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
$services->set(DowngradeNamedArgumentRector::class); | ||
}; |
Oops, something went wrong.