mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
make tests pass again
This commit is contained in:
parent
b24c4e3717
commit
1622d0c49d
@ -3,7 +3,6 @@
|
||||
namespace Rector\BetterReflection\Reflector;
|
||||
|
||||
use Rector\BetterReflection\Reflection\ReflectionMethod;
|
||||
use Rector\BetterReflection\Reflector\Exception\IdentifierNotFound;
|
||||
|
||||
final class MethodReflector
|
||||
{
|
||||
@ -19,12 +18,7 @@ final class MethodReflector
|
||||
|
||||
public function reflectClassMethod(string $class, string $method): ?ReflectionMethod
|
||||
{
|
||||
try {
|
||||
$classReflection = $this->smartClassReflector->reflect($class);
|
||||
} catch (IdentifierNotFound $identifierNotFoundException) {
|
||||
// class doesn't exist
|
||||
return null;
|
||||
}
|
||||
$classReflection = $this->smartClassReflector->reflect($class);
|
||||
|
||||
if ($classReflection === null) {
|
||||
return null;
|
||||
|
@ -180,7 +180,7 @@ class Configurator extends Object
|
||||
|
||||
/**
|
||||
* Returns system DI container.
|
||||
* @return DI\Container
|
||||
* @return \Nette\DI\Container
|
||||
*/
|
||||
public function createContainer()
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Rector\NodeTypeResolver\PerNodeTypeResolver;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
@ -53,7 +54,6 @@ final class AssignTypeResolver implements PerNodeTypeResolverInterface, NodeType
|
||||
|
||||
// $var = $anotherVar;
|
||||
if ($assignNode->expr instanceof Variable) {
|
||||
// return $this->nodeTypeResolver->resolve($assignNode->expr);
|
||||
return $this->processAssignVariableNode($assignNode);
|
||||
}
|
||||
|
||||
@ -130,12 +130,23 @@ final class AssignTypeResolver implements PerNodeTypeResolverInterface, NodeType
|
||||
|
||||
if ($methodReflection) {
|
||||
$returnType = $methodReflection->getReturnType();
|
||||
|
||||
if ($returnType) {
|
||||
return (string) $returnType;
|
||||
}
|
||||
|
||||
$returnTypes = $methodReflection->getDocBlockReturnTypes();
|
||||
|
||||
if (! isset($returnTypes[0])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($returnTypes[0] instanceof Object_) {
|
||||
return ltrim((string) $returnTypes[0]->getFqsen(), '\\');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->fallbackStaticType($methodCallVariableType, $methodCallName);
|
||||
return null;
|
||||
}
|
||||
|
||||
private function resolveMethodCallName(Assign $assignNode): ?string
|
||||
@ -151,18 +162,4 @@ final class AssignTypeResolver implements PerNodeTypeResolverInterface, NodeType
|
||||
|
||||
return (string) $assignNode->expr->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy static method call return type that doesn't depend on class reflection.
|
||||
*
|
||||
* @todo use stubs instead
|
||||
*/
|
||||
private function fallbackStaticType(string $type, string $methodName): ?string
|
||||
{
|
||||
if ($type === 'Nette\Config\Configurator' && $methodName === 'createContainer') {
|
||||
return 'Nette\DI\Container';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user