mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-14 20:41:58 +02:00
[MagicDisclosure] Fix property assign magic call [closes #1190]
This commit is contained in:
parent
0543a5a2ab
commit
c5f51e5cb1
@ -18,7 +18,6 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
|
||||
final class ProcessCommand extends AbstractCommand
|
||||
{
|
||||
@ -70,8 +69,11 @@ final class ProcessCommand extends AbstractCommand
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $fileExtensions;
|
||||
private $fileExtensions = [];
|
||||
|
||||
/**
|
||||
* @param string[] $fileExtensions
|
||||
*/
|
||||
public function __construct(
|
||||
SymfonyStyle $symfonyStyle,
|
||||
FilesFinder $phpFilesFinder,
|
||||
|
@ -118,10 +118,6 @@ CODE_SAMPLE
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->propertyFetchManipulator->isPropertyToSelf($propertyFetchNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $this->propertyFetchManipulator->isMagicOnType($propertyFetchNode, $type)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Fixture;
|
||||
|
||||
use Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Source\Klarka;
|
||||
|
||||
class KlarkaExtended extends Klarka
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
if ($this->leafBreadcrumbCategory) {
|
||||
$category = $this->leafBreadcrumbCategory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Fixture;
|
||||
|
||||
use Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Source\Klarka;
|
||||
|
||||
class KlarkaExtended extends Klarka
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
if ($this->get('leafBreadcrumbCategory')) {
|
||||
$category = $this->get('leafBreadcrumbCategory');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -4,19 +4,19 @@ namespace Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector;
|
||||
|
||||
use Rector\Rector\MagicDisclosure\GetAndSetToMethodCallRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Source\Klarka;
|
||||
use Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Source\SomeContainer;
|
||||
|
||||
final class GetAndSetToMethodCallRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$this->doTestFiles(
|
||||
[
|
||||
__DIR__ . '/Fixture/fixture.php.inc',
|
||||
__DIR__ . '/Fixture/fixture2.php.inc',
|
||||
__DIR__ . '/Fixture/fixture3.php.inc',
|
||||
]
|
||||
);
|
||||
$this->doTestFiles([
|
||||
__DIR__ . '/Fixture/fixture.php.inc',
|
||||
__DIR__ . '/Fixture/fixture2.php.inc',
|
||||
__DIR__ . '/Fixture/fixture3.php.inc',
|
||||
__DIR__ . '/Fixture/klarka.php.inc',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
@ -38,6 +38,9 @@ final class GetAndSetToMethodCallRectorTest extends AbstractRectorTestCase
|
||||
'get' => 'getService',
|
||||
'set' => 'addService',
|
||||
],
|
||||
Klarka::class => [
|
||||
'get' => 'get',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\MagicDisclosure\GetAndSetToMethodCallRector\Source;
|
||||
|
||||
class Klarka
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user