-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test fixture for RemoveParentCallWithoutParentRector (#711)
* Add failing test fixture for RemoveParentCallWithoutParentRector * Add test for PHP 7.4 * Try to fix. * Skip anonymous class * Fix circular mixin * Use ClassAnalyzer service for detecting anonymous class * Revert "Use ClassAnalyzer service for detecting anonymous class" This reverts commit c2ed3c2. * improve performance
- Loading branch information
1 parent
7095dca
commit 9f311dc
Showing
4 changed files
with
116 additions
and
32 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
26 changes: 26 additions & 0 deletions
26
...veParentCallWithoutParentRector/FixturePhp74/parent_with_return_and_used_in_mixin.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,26 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector\Fixture; | ||
|
||
class ParentWithReturnAndUsedInMixin extends SomeClass | ||
{ | ||
public function getIncrementing() | ||
{ | ||
return parent::getIncrementing(); | ||
} | ||
} | ||
|
||
class SomeClass | ||
{ | ||
public function getIncrementing() | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* @mixin SomeClass | ||
*/ | ||
class SomeUnrelatedClass | ||
{ | ||
} |
33 changes: 33 additions & 0 deletions
33
rules-tests/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector/Php74Test.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\Tests\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class Php74Test extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixturePhp74'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/php74.php'; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
rules-tests/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector/config/php74.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Rector\Core\ValueObject\PhpVersion; | ||
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(RemoveParentCallWithoutParentRector::class); | ||
}; |