public function testValuesWithNullFilename()
 {
     $source = '<?php echo "Hello world";';
     $file = null;
     $locatedSource = new LocatedSource($source, $file);
     $this->assertSame($source, $locatedSource->getSource());
     $this->assertNull($locatedSource->getFileName());
     $this->assertFalse($locatedSource->isEvaled());
     $this->assertFalse($locatedSource->isInternal());
 }
 /**
  * @param LocatedSource $locatedSource
  * @param \Exception|\Throwable $previous
  * @return ParseToAstFailure
  */
 public static function fromLocatedSource(LocatedSource $locatedSource, $previous = null)
 {
     $additionalInformation = '';
     if (null !== $locatedSource->getFileName()) {
         $additionalInformation = sprintf(' (in %s)', $locatedSource->getFileName());
     }
     if ($additionalInformation === '') {
         $additionalInformation = sprintf(' (first 20 characters: %s)', substr($locatedSource->getSource(), 0, 20));
     }
     return new self(sprintf('AST failed to parse in located source%s', $additionalInformation), 0, $previous);
 }
 /**
  * Given an AST type, attempt to find a resolved type.
  *
  * @param $astType
  * @param LocatedSource $locatedSource
  * @param string $namespace
  * @return \phpDocumentor\Reflection\Type|null
  */
 public function __invoke($astType, LocatedSource $locatedSource, $namespace = '')
 {
     $context = (new ContextFactory())->createForNamespace($namespace, $locatedSource->getSource());
     if (is_string($astType)) {
         $typeString = $astType;
     }
     if ($astType instanceof Name) {
         $typeString = $astType->toString();
     }
     // If the AST determined this is a "fully qualified" name, prepend \
     if ($astType instanceof Name\FullyQualified) {
         $typeString = '\\' . $typeString;
     }
     if (!isset($typeString)) {
         return null;
     }
     $types = (new ResolveTypes())->__invoke([$typeString], $context);
     return reset($types);
 }
 /**
  * Is this an internal class?
  *
  * @return bool
  */
 public function isInternal()
 {
     return $this->locatedSource->isInternal();
 }
 /**
  * @return string
  */
 public function getFileName()
 {
     return $this->locatedSource->getFileName();
 }