-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp70][DowngradePhp80] Test for combine DowngradeScalarType…
…DeclarationRector + DowngradeStringReturnTypeOnToStringRector (#1751)
- Loading branch information
1 parent
f632fa0
commit c5482e2
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
tests/Issues/DowngradeScalarString/DowngradeScalarStringTest.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeScalarString; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class DowngradeScalarStringTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
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'; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
tests/Issues/DowngradeScalarString/Fixture/return_string.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,49 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeScalarString\Fixture; | ||
|
||
abstract class AbstractReturnString | ||
{ | ||
public function __toString(): string | ||
{ | ||
return 'value'; | ||
} | ||
} | ||
|
||
class ReturnString extends AbstractReturnString | ||
{ | ||
public function __toString() | ||
{ | ||
return 'value'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeScalarString\Fixture; | ||
|
||
abstract class AbstractReturnString | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return 'value'; | ||
} | ||
} | ||
|
||
class ReturnString extends AbstractReturnString | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return 'value'; | ||
} | ||
} | ||
|
||
?> |
13 changes: 13 additions & 0 deletions
13
tests/Issues/DowngradeScalarString/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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector; | ||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStringReturnTypeOnToStringRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
$services->set(DowngradeStringReturnTypeOnToStringRector::class); | ||
$services->set(DowngradeScalarTypeDeclarationRector::class); | ||
}; |