[cs + st]

This commit is contained in:
Tomas Votruba 2018-04-10 08:54:20 +02:00
parent 99b0b4c0fd
commit a3e2d98c05
2 changed files with 9 additions and 7 deletions

View File

@ -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;

View File

@ -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 { }'),
]);
}