예제 #1
0
 /**
  * @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);
 }
 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());
 }
예제 #3
0
 /**
  * @return string|null
  */
 public function getFileName()
 {
     return $this->locatedSource->getFileName();
 }