mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 19:53:14 +01:00
[cs + st]
This commit is contained in:
parent
99b0b4c0fd
commit
a3e2d98c05
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Rector\Rector\Architecture\RepositoryAsService;
|
||||
|
||||
use get_class;
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
@ -119,6 +118,9 @@ CODE_SAMPLE
|
||||
return ! Strings::endsWith($className, 'Repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$repositoryFqn = $this->repositoryFqn($node);
|
||||
@ -134,9 +136,9 @@ CODE_SAMPLE
|
||||
);
|
||||
}
|
||||
|
||||
private function repositoryFqn(Node $node): string
|
||||
private function repositoryFqn(MethodCall $methodCallNode): string
|
||||
{
|
||||
$entityFqnOrAlias = $this->entityFqnOrAlias($node);
|
||||
$entityFqnOrAlias = $this->entityFqnOrAlias($methodCallNode);
|
||||
|
||||
$repositoryClassName = $this->repositoryForDoctrineEntityProvider->provideRepositoryForEntity(
|
||||
$entityFqnOrAlias
|
||||
@ -153,11 +155,9 @@ CODE_SAMPLE
|
||||
));
|
||||
}
|
||||
|
||||
private function entityFqnOrAlias(Node $node): string
|
||||
private function entityFqnOrAlias(MethodCall $methodCallNode): string
|
||||
{
|
||||
/** @var MethodCall $methodCall */
|
||||
$methodCall = $node;
|
||||
$repositoryArgument = $methodCall->args[0]->value;
|
||||
$repositoryArgument = $methodCallNode->args[0]->value;
|
||||
|
||||
if ($repositoryArgument instanceof String_) {
|
||||
return $repositoryArgument->value;
|
||||
|
@ -22,6 +22,8 @@ final class ValueObjectRemoverRector extends AbstractValueObjectRemoverRector
|
||||
'function someFunction(ValueObject $name) { }',
|
||||
'function someFunction(string $name) { }'
|
||||
),
|
||||
new CodeSample('function someFunction(): ValueObject { }', 'function someFunction(): string { }'),
|
||||
new CodeSample('function someFunction(): ?ValueObject { }', 'function someFunction(): ?string { }'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user