mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
add definition
This commit is contained in:
parent
e9988f6b4c
commit
8dc8d30be0
@ -8,6 +8,9 @@ use PhpParser\Node\Identifier;
|
||||
use Rector\BetterReflection\Reflector\SmartClassReflector;
|
||||
use Rector\Node\PropertyFetchNodeFactory;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends AbstractRector
|
||||
{
|
||||
@ -53,6 +56,7 @@ final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends Abstr
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo should be part of reflection
|
||||
* @return string[]
|
||||
*/
|
||||
private function getEntityRepositoryPublicMethodNames(): array
|
||||
@ -65,4 +69,40 @@ final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends Abstr
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Handles method calls in child of Doctrine EntityRepository and moves them to "$this->repository" property.',
|
||||
new CodeSample(
|
||||
<<<'SAMPLE'
|
||||
<?php
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class SomeRepository extends EntityRepository
|
||||
{
|
||||
public function someMethod()
|
||||
{
|
||||
return $this->findAll();
|
||||
}
|
||||
}
|
||||
SAMPLE
|
||||
,
|
||||
<<<'SAMPLE_TWO'
|
||||
<?php
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class SomeRepository extends EntityRepository
|
||||
{
|
||||
public function someMethod()
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
}
|
||||
SAMPLE_TWO
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user