Roave / BetterReflection

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
MIT License
1.18k stars 131 forks source link

ReflectionClass expected, null given #190

Closed Danack closed 8 years ago

Danack commented 8 years ago

Seems to be an internal error:

Output:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to BetterReflection\Reflection\ReflectionClass::BetterReflection\Reflection\{closure}() must be an instance of BetterReflection\Reflection\ReflectionClass, null given in /home/github/GithubArtaxService/GithubArtaxService/vendor/roave/better-reflection/src/Reflection/ReflectionClass.php:299
Stack trace:
#0 [internal function]: BetterReflection\Reflection\ReflectionClass->BetterReflection\Reflection\{closure}(NULL)
#1 /home/github/GithubArtaxService/GithubArtaxService/vendor/roave/better-reflection/src/Reflection/ReflectionClass.php(305): array_map(Object(Closure), Array)
#2 /home/github/GithubArtaxService/GithubArtaxService/vendor/roave/better-reflection/src/Reflection/ReflectionClass.php(332): BetterReflection\Reflection\ReflectionClass->scanMethods()
#3 /home/github/GithubArtaxService/GithubArtaxService/vendor/roave/better-reflection/src/Reflection/ReflectionClass.php(345): BetterReflection\Reflection\ReflectionClass->getMethodsIndexedByName()
#4 /home/github/GithubArtax in /home/github/GithubArtaxService/GithubArtaxService/vendor/roave/better-reflection/src/Reflection/ReflectionClass.php on line 299

Code to reproduce error:

<?php

use BetterReflection\Reflector\ClassReflector;
use BetterReflection\SourceLocator\Type\SingleFileSourceLocator;

$autoloader = require __DIR__.'/../vendor/autoload.php';

exec('wget --no-check-certificate https://raw.githubusercontent.com/slimphp/Slim/e08856b997891e9303c72120d766434b13874b71/Slim/App.php');

$sourceLocator = new SingleFileSourceLocator("./App.php");

$reflector = new ClassReflector($sourceLocator);
$reflClass = $reflector->reflect('Slim\App');

$properties = $reflClass->getProperties();
$methods = $reflClass->getMethods();
asgrim commented 8 years ago

Duplicate of #189