Skip to content

Commit

Permalink
[DowngradePhp70][DowngradePhp80] Test for combine DowngradeScalarType…
Browse files Browse the repository at this point in the history
…DeclarationRector + DowngradeStringReturnTypeOnToStringRector (#1751)
  • Loading branch information
samsonasik committed Jan 31, 2022
1 parent f632fa0 commit c5482e2
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Issues/DowngradeScalarString/DowngradeScalarStringTest.php
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 tests/Issues/DowngradeScalarString/Fixture/return_string.php.inc
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 tests/Issues/DowngradeScalarString/config/configured_rule.php
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);
};

0 comments on commit c5482e2

Please sign in to comment.