[BetterReflection] drop missing identifier fallback where not needed - towards autoloadble

This commit is contained in:
Tomas Votruba 2018-05-31 01:37:33 +02:00
parent 8b7b422eb8
commit 4c43702608
4 changed files with 5 additions and 32 deletions

View File

@ -7,7 +7,6 @@ use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\Self_; use phpDocumentor\Reflection\Types\Self_;
use phpDocumentor\Reflection\Types\Static_; use phpDocumentor\Reflection\Types\Static_;
use Roave\BetterReflection\Reflection\ReflectionMethod; use Roave\BetterReflection\Reflection\ReflectionMethod;
use Roave\BetterReflection\Reflector\Exception\IdentifierNotFound;
use Throwable; use Throwable;
final class MethodReflector final class MethodReflector
@ -24,12 +23,7 @@ final class MethodReflector
public function reflectClassMethod(string $class, string $method): ?ReflectionMethod public function reflectClassMethod(string $class, string $method): ?ReflectionMethod
{ {
try { $classReflection = $this->smartClassReflector->reflect($class);
$classReflection = $this->smartClassReflector->reflect($class);
} catch (IdentifierNotFound $identifierNotFoundException) {
return null;
}
if ($classReflection === null) { if ($classReflection === null) {
return null; return null;
} }

View File

@ -5,7 +5,6 @@ namespace Rector\BetterReflection\Reflector;
use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Object_;
use Roave\BetterReflection\Reflection\ReflectionProperty; use Roave\BetterReflection\Reflection\ReflectionProperty;
use Roave\BetterReflection\Reflector\Exception\IdentifierNotFound;
final class PropertyReflector final class PropertyReflector
{ {
@ -26,12 +25,7 @@ final class PropertyReflector
public function reflectClassProperty(string $class, string $method): ?ReflectionProperty public function reflectClassProperty(string $class, string $method): ?ReflectionProperty
{ {
try { $classReflection = $this->smartClassReflector->reflect($class);
$classReflection = $this->smartClassReflector->reflect($class);
} catch (IdentifierNotFound $identifierNotFoundException) {
return null;
}
if ($classReflection === null) { if ($classReflection === null) {
return null; return null;
} }

View File

@ -108,12 +108,7 @@ final class SmartClassReflector
*/ */
public function resolveClassInterfaces(ReflectionClass $reflectionClass): array public function resolveClassInterfaces(ReflectionClass $reflectionClass): array
{ {
try { return array_keys($reflectionClass->getInterfaces());
return array_keys($reflectionClass->getInterfaces());
} catch (IdentifierNotFound $identifierNotFoundException) {
// @todo check if type is needed by any Rector
return [];
}
} }
/** /**
@ -121,12 +116,7 @@ final class SmartClassReflector
*/ */
public function resolveClassParents(ReflectionClass $reflectionClass): array public function resolveClassParents(ReflectionClass $reflectionClass): array
{ {
try { return $reflectionClass->getParentClassNames();
return $reflectionClass->getParentClassNames();
} catch (IdentifierNotFound $identifierNotFoundException) {
// @todo check if type is needed by any Rector
return [];
}
} }
/** /**

View File

@ -6,7 +6,6 @@ use Rector\BetterReflection\Stubber\SourceStubber;
use Roave\BetterReflection\Identifier\Identifier; use Roave\BetterReflection\Identifier\Identifier;
use Roave\BetterReflection\Identifier\IdentifierType; use Roave\BetterReflection\Identifier\IdentifierType;
use Roave\BetterReflection\Reflection\Reflection; use Roave\BetterReflection\Reflection\Reflection;
use Roave\BetterReflection\Reflector\Exception\IdentifierNotFound;
use Roave\BetterReflection\Reflector\Reflector; use Roave\BetterReflection\Reflector\Reflector;
use Roave\BetterReflection\SourceLocator\Ast\Locator; use Roave\BetterReflection\SourceLocator\Ast\Locator;
use Roave\BetterReflection\SourceLocator\Located\LocatedSource; use Roave\BetterReflection\SourceLocator\Located\LocatedSource;
@ -47,11 +46,7 @@ final class StubSourceLocator implements SourceLocator
$locatedSource = new LocatedSource($stubFileInfo->getContents(), $stubFileInfo->getRealPath()); $locatedSource = new LocatedSource($stubFileInfo->getContents(), $stubFileInfo->getRealPath());
try { return $this->astLocator->findReflection($reflector, $locatedSource, $identifier);
return $this->astLocator->findReflection($reflector, $locatedSource, $identifier);
} catch (IdentifierNotFound $identifierNotFoundException) {
return null;
}
} }
/** /**