-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp72] Allow empty config on DowngradeParameterTypeWidening…
…Rector (#1451) * [DowngradePhp72] Allow empty config on DowngradeParameterTypeWideningRector * [ci-review] Rector Rectify * fix * early check on empty unsafeTypesToMethods * added back removed fixture * final touch: eol Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
8d6eb87
commit 4681067
Showing
14 changed files
with
513 additions
and
18 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
34 changes: 34 additions & 0 deletions
34
...owngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector/EmptyConfigTest.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\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class EmptyConfigTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @requires PHP 7.2 | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureEmptyConfig'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/empty_config.php'; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...assMethod/DowngradeParameterTypeWideningRector/FixtureEmptyConfig/anonymous_class.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,55 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
class SomeClass | ||
{ | ||
public function hello(string $world = 'world') { | ||
printf('Hello %s', $world); | ||
} | ||
} | ||
|
||
class SomeOtherClassUsingAnAnonymousClass | ||
{ | ||
public function doSomething(): void | ||
{ | ||
$class = new class () extends SomeClass { | ||
public function hello(string $world = 'world') { | ||
printf('Hi %s', $world); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
class SomeClass | ||
{ | ||
/** | ||
* @param string $world | ||
*/ | ||
public function hello($world = 'world') { | ||
printf('Hello %s', $world); | ||
} | ||
} | ||
|
||
class SomeOtherClassUsingAnAnonymousClass | ||
{ | ||
public function doSomething(): void | ||
{ | ||
$class = new class () extends SomeClass { | ||
/** | ||
* @param string $world | ||
*/ | ||
public function hello($world = 'world') { | ||
printf('Hi %s', $world); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
?> |
65 changes: 65 additions & 0 deletions
65
...wngradeParameterTypeWideningRector/FixtureEmptyConfig/anonymous_class_alternative.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,65 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeInterface | ||
{ | ||
public function hello(string $world = 'world'); | ||
} | ||
|
||
class SomeClass2 | ||
{ | ||
public function doSomething(): void | ||
{ | ||
$class = new class (function () { | ||
return $this->doSomethingElse(); | ||
}) implements SomeInterface { | ||
public function hello(string $world = 'world') { | ||
printf('Hi %s', $world); | ||
} | ||
}; | ||
} | ||
|
||
public function doSomethingElse(): void | ||
{ | ||
print('Hello again'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeInterface | ||
{ | ||
/** | ||
* @param string $world | ||
*/ | ||
public function hello($world = 'world'); | ||
} | ||
|
||
class SomeClass2 | ||
{ | ||
public function doSomething(): void | ||
{ | ||
$class = new class (function () { | ||
return $this->doSomethingElse(); | ||
}) implements SomeInterface { | ||
/** | ||
* @param string $world | ||
*/ | ||
public function hello($world = 'world') { | ||
printf('Hi %s', $world); | ||
} | ||
}; | ||
} | ||
|
||
public function doSomethingElse(): void | ||
{ | ||
print('Hello again'); | ||
} | ||
} | ||
|
||
?> |
57 changes: 57 additions & 0 deletions
57
...arameterTypeWideningRector/FixtureEmptyConfig/anonymous_return_abstract_interface.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,57 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeInterface2 | ||
{ | ||
public function test(\SplFileInfo $file); | ||
} | ||
|
||
abstract class SomeAbstractClass implements SomeInterface2 | ||
{ | ||
public function test2(\SplFileInfo $file, string $world = 'world') { | ||
printf('Hello %s', $world); | ||
} | ||
} | ||
|
||
return new class extends SomeAbstractClass { | ||
public function test(\SplFileInfo $file) { | ||
$this->test2($file); | ||
} | ||
}; | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeInterface2 | ||
{ | ||
/** | ||
* @param \SplFileInfo $file | ||
*/ | ||
public function test($file); | ||
} | ||
|
||
abstract class SomeAbstractClass implements SomeInterface2 | ||
{ | ||
/** | ||
* @param \SplFileInfo $file | ||
* @param string $world | ||
*/ | ||
public function test2($file, $world = 'world') { | ||
printf('Hello %s', $world); | ||
} | ||
} | ||
|
||
return new class extends SomeAbstractClass { | ||
/** | ||
* @param \SplFileInfo $file | ||
*/ | ||
public function test($file) { | ||
$this->test2($file); | ||
} | ||
}; | ||
|
||
?> |
52 changes: 52 additions & 0 deletions
52
...d/DowngradeParameterTypeWideningRector/FixtureEmptyConfig/container_has_interface.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,52 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeContainerInterface | ||
{ | ||
public function has(string $id); | ||
} | ||
|
||
final class SomeContainerBuilder extends SomeUniqueContainer | ||
{ | ||
public function has($id) | ||
{ | ||
} | ||
} | ||
|
||
class SomeUniqueContainer implements SomeContainerInterface | ||
{ | ||
public function has($id) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface SomeContainerInterface | ||
{ | ||
/** | ||
* @param string $id | ||
*/ | ||
public function has($id); | ||
} | ||
|
||
final class SomeContainerBuilder extends SomeUniqueContainer | ||
{ | ||
public function has($id) | ||
{ | ||
} | ||
} | ||
|
||
class SomeUniqueContainer implements SomeContainerInterface | ||
{ | ||
public function has($id) | ||
{ | ||
} | ||
} | ||
|
||
?> |
55 changes: 55 additions & 0 deletions
55
...ector/ClassMethod/DowngradeParameterTypeWideningRector/FixtureEmptyConfig/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,55 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface A | ||
{ | ||
public function test(array $input); | ||
} | ||
|
||
class B implements A | ||
{ | ||
public function test($input) | ||
{ | ||
} | ||
} | ||
|
||
final class MostChild implements A | ||
{ | ||
public function test(array $input) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
interface A | ||
{ | ||
/** | ||
* @param mixed[] $input | ||
*/ | ||
public function test($input); | ||
} | ||
|
||
class B implements A | ||
{ | ||
public function test($input) | ||
{ | ||
} | ||
} | ||
|
||
final class MostChild implements A | ||
{ | ||
/** | ||
* @param mixed[] $input | ||
*/ | ||
public function test($input) | ||
{ | ||
} | ||
} | ||
|
||
?> |
42 changes: 42 additions & 0 deletions
42
...Method/DowngradeParameterTypeWideningRector/FixtureEmptyConfig/include_used_trait.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,42 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
use Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Source\AnotherContainerInterface; | ||
|
||
final class YetAnotherContainer implements AnotherContainerInterface | ||
{ | ||
use AnotherServiceLocatorTrait; | ||
} | ||
|
||
trait AnotherServiceLocatorTrait | ||
{ | ||
public function get(string $name) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\FixtureEmptyConfig; | ||
|
||
use Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Source\AnotherContainerInterface; | ||
|
||
final class YetAnotherContainer implements AnotherContainerInterface | ||
{ | ||
use AnotherServiceLocatorTrait; | ||
} | ||
|
||
trait AnotherServiceLocatorTrait | ||
{ | ||
/** | ||
* @param string $name | ||
*/ | ||
public function get($name) | ||
{ | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.