simplify PropertyFetchTypeResolver

This commit is contained in:
TomasVotruba 2018-01-08 21:25:56 +01:00
parent 5abdf00f52
commit e32ed6a300
2 changed files with 2 additions and 6 deletions

View File

@ -5,7 +5,6 @@ namespace Rector\NodeTypeResolver\PerNodeTypeResolver;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
@ -54,14 +53,10 @@ final class PropertyFetchTypeResolver implements PerNodeTypeResolverInterface, N
*/
public function resolve(Node $propertyFetchNode): array
{
if ($propertyFetchNode->name instanceof Variable ||
$propertyFetchNode->name instanceof ArrayDimFetch ||
$propertyFetchNode->name instanceof Concat
) {
if (! $propertyFetchNode->name instanceof Identifier) {
return $this->nodeTypeResolver->resolve($propertyFetchNode->name);
}
/** @var Identifier $identifierNode */
$identifierNode = $propertyFetchNode->name;
$propertyName = $identifierNode->toString();

View File

@ -35,6 +35,7 @@ parameters:
- '#Method Rector\\BetterReflection\\Reflector\\SmartClassReflector::reflect\(\) should return Rector\\BetterReflection\\Reflection\\ReflectionClass\|null but returns Rector\\BetterReflection\\Reflection\\Reflection#'
- '#Property Rector\\NodeTypeResolver\\Tests\\PerNodeCallerTypeResolver\\MethodCallCallerTypeResolver\\NestedMethodCallTest::\$(formChainMethodCallNodes|nestedMethodCallNodes) \(array<PhpParser\\Node\\Expr\\MethodCall>\) does not accept array<PhpParser\\Node>#'
- '#Cannot call method toString\(\) on string#'
- '#Parameter \#1 \$node of method Rector\\NodeTypeResolver\\NodeTypeResolver::resolve\(\) expects PhpParser\\Node, PhpParser\\Node\\Expr|string given#'
# known value of Name of MethodCall
- '#Call to an undefined method PhpParser\\Node\\Expr\|PhpParser\\Node\\Name::toString\(\)#'