fromLocatedSource() 공개 정적인 메소드

public static fromLocatedSource ( BetterReflection\SourceLocator\Located\LocatedSource $locatedSource, Exception | Throwable $previous = null ) : ParseToAstFailure
$locatedSource BetterReflection\SourceLocator\Located\LocatedSource
$previous Exception | Throwable
리턴 ParseToAstFailure
예제 #1
0
 /**
  * Get an array of reflections found in some code.
  *
  * @param Reflector $reflector
  * @param LocatedSource $locatedSource
  * @param IdentifierType $identifierType
  * @return \BetterReflection\Reflection\Reflection[]
  * @throws Exception\ParseToAstFailure
  */
 public function findReflectionsOfType(Reflector $reflector, LocatedSource $locatedSource, IdentifierType $identifierType)
 {
     try {
         return $this->findReflectionsInTree->__invoke($reflector, $this->parser->parse($locatedSource->getSource()), $identifierType, $locatedSource);
     } catch (\Exception $exception) {
         throw Exception\ParseToAstFailure::fromLocatedSource($locatedSource, $exception);
     } catch (\Throwable $exception) {
         throw Exception\ParseToAstFailure::fromLocatedSource($locatedSource, $exception);
     }
 }
 public function testFromLocatedSourceWithFilename()
 {
     $locatedSource = new LocatedSource('<?php abc', null);
     $filenameProperty = new \ReflectionProperty($locatedSource, 'filename');
     $filenameProperty->setAccessible(true);
     $filenameProperty->setValue($locatedSource, '/foo/bar');
     $previous = new \Exception();
     $exception = ParseToAstFailure::fromLocatedSource($locatedSource, $previous);
     $this->assertInstanceOf(ParseToAstFailure::class, $exception);
     $this->assertSame('AST failed to parse in located source (in /foo/bar)', $exception->getMessage());
     $this->assertSame($previous, $exception->getPrevious());
 }