PHPSA\Application::getIssuesCollector PHP Method

getIssuesCollector() public method

Get the IssuesCollector object.
public getIssuesCollector ( ) : IssuesCollector
return IssuesCollector
    public function getIssuesCollector()
    {
        return $this->issuesCollector;
    }

Usage Example

Example #1
0
 /**
  * @dataProvider provideTestParseAndDump
  *
  * @param $file
  * @param string $analyzer
  * @param string $expectedDump
  * @throws \PHPSA\Exception\RuntimeException
  * @throws \Webiny\Component\EventManager\EventManagerException
  */
 public function testParseAndDump($file, $analyzer, $expectedDump)
 {
     $compiler = new Compiler();
     $fileParser = new FileParser((new ParserFactory())->create(ParserFactory::PREFER_PHP7, new \PhpParser\Lexer\Emulative(array('usedAttributes' => array('comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos')))), $compiler);
     $context = new Context(new \Symfony\Component\Console\Output\NullOutput(), $application = new Application(), $this->getEventManager($analyzer));
     $application->compiler = $compiler;
     $fileParser->parserFile($file, $context);
     $compiler->compile($context);
     $expectedArray = json_decode($expectedDump, true);
     $expectedType = $expectedArray[0]["type"];
     $issues = array_map(function (Issue $issue) {
         $location = $issue->getLocation();
         return ['type' => $issue->getCheckName(), 'message' => $issue->getDescription(), 'file' => $location->getFileName(), 'line' => $location->getLineStart()];
     }, $application->getIssuesCollector()->getIssues());
     foreach ($expectedArray as $check) {
         self::assertContains($check, $issues, $file);
         // every expected Issue is in the collector
     }
     foreach ($issues as $check) {
         if ($check["type"] == $expectedType) {
             self::assertContains($check, $expectedArray, $file);
             // there is no other issue in the collector with the same type
         }
     }
 }
All Usage Examples Of PHPSA\Application::getIssuesCollector