public function testFromNonObject()
 {
     $identifier = new Identifier('myIdentifier', new IdentifierType(IdentifierType::IDENTIFIER_CLASS));
     $exception = IdentifierNotFound::fromIdentifier($identifier);
     $this->assertInstanceOf(IdentifierNotFound::class, $exception);
     $this->assertSame(IdentifierType::IDENTIFIER_CLASS . ' "myIdentifier" could not be found in the located source', $exception->getMessage());
     $this->assertSame($identifier, $exception->getIdentifier());
 }
 /**
  * Create a ReflectionClass for the specified $className.
  *
  * @param string $className
  * @return \BetterReflection\Reflection\ReflectionClass
  */
 public function reflect($className)
 {
     $identifier = new Identifier($className, new IdentifierType(IdentifierType::IDENTIFIER_CLASS));
     $classInfo = $this->sourceLocator->locateIdentifier($this, $identifier);
     if (null === $classInfo) {
         throw Exception\IdentifierNotFound::fromIdentifier($identifier);
     }
     return $classInfo;
 }
Exemple #3
0
 /**
  * Given an array of Reflections, try to find the identifier.
  *
  * @param Reflection[] $reflections
  * @param Identifier $identifier
  * @return Reflection
  */
 private function findInArray($reflections, Identifier $identifier)
 {
     foreach ($reflections as $reflection) {
         if ($reflection->getName() === $identifier->getName()) {
             return $reflection;
         }
     }
     throw Exception\IdentifierNotFound::fromIdentifier($identifier);
 }