/**
  * @param string $path
  * @return FluidParserResult[]
  */
 public function syntaxCheckPhpFilesInPath($path)
 {
     $files = GlobUtility::getFilesRecursive($path, 'php');
     $files = array_values($files);
     $results = array();
     foreach ($files as $filePathAndFilename) {
         $results[$filePathAndFilename] = $this->syntaxCheckPhpFile($filePathAndFilename);
     }
     return $results;
 }
 /**
  * Syntax check Fluid template
  *
  * Checks one template file, all templates in
  * an extension or a sub-path (which can be used
  * with an extension key for a relative path).
  * If left out, it will lint ALL templates in
  * EVERY local extension.
  *
  * @param string $extension Optional extension key (if path is set too it will apply to sub-folders in extension)
  * @param string $path file or folder path (if extensionKey is included, path is relative to this extension)
  * @param string $extensions If provided, this CSV list of file extensions are considered Fluid templates
  * @param boolean $verbose If TRUE outputs more information about each file check - default is to only output errors
  * @throws \RuntimeException
  * @return void
  */
 public function fluidSyntaxCommand($extension = null, $path = null, $extensions = 'html,xml,txt', $verbose = false)
 {
     $verbose = (bool) $verbose;
     if (null !== $extension) {
         $this->assertEitherExtensionKeyOrPathOrBothAreProvidedOrExit($extension, $path);
         $path = GlobUtility::getRealPathFromExtensionKeyAndPath($extension, $path);
         $files = GlobUtility::getFilesRecursive($path, $extensions);
     } else {
         // no extension key given, let's lint it all
         if (6 > substr(TYPO3_version, 0, 1)) {
             throw new \RuntimeException('Listing extensions via core API only works on 6.0+. Won\'t fix.', 1376379122);
         }
         $files = [];
         /** @var ExtensionService $extensionService */
         $extensionService = $this->objectManager->get('FluidTYPO3\\Builder\\Service\\ExtensionService');
         $extensionInformation = $extensionService->getComputableInformation();
         foreach ($extensionInformation as $extensionName => $extensionInfo) {
             // Syntax service declines linting of inactive extensions
             if (0 === intval($extensionInfo['installed']) || 'System' === $extensionInfo['type']) {
                 continue;
             }
             $path = GlobUtility::getRealPathFromExtensionKeyAndPath($extensionName, null);
             $files = array_merge($files, GlobUtility::getFilesRecursive($path, $extensions));
         }
     }
     $files = array_values($files);
     $errors = false;
     $this->response->setContent('Performing a syntax check on fluid templates (types: ' . $extensions . '; path: ' . $path . ')' . LF);
     $this->response->send();
     foreach ($files as $filePathAndFilename) {
         $basePath = str_replace(PATH_site, '', $filePathAndFilename);
         $result = $this->syntaxService->syntaxCheckFluidTemplateFile($filePathAndFilename);
         if (null !== $result->getError()) {
             $this->response->appendContent('[ERROR] File ' . $basePath . ' has an error: ' . LF);
             $this->response->appendContent($result->getError()->getMessage() . ' (' . $result->getError()->getCode() . ')' . LF);
             $this->response->send();
             $errors = true;
         } elseif (true === $verbose) {
             $namespaces = $result->getNamespaces();
             $this->response->appendContent('File is compilable: ' . ($result->getCompilable() ? 'YES' : 'NO (WARNING)') . LF);
             if ($result->getLayoutName()) {
                 $this->response->appendContent('File has layout (' . $result->getLayoutName() . ')' . LF);
             } else {
                 $this->response->appendContent('File DOES NOT reference a Layout' . LF);
             }
             $this->response->appendContent('File has ' . count($namespaces) . ' namespace(s)' . (0 < count($namespaces) ? ': ' . $result->getNamespacesFlattened() : '') . LF);
             $this->response->appendContent('[OK] File  ' . $basePath . ' is valid.' . LF);
             $this->response->send();
         }
         $this->response->setContent(LF);
     }
     $this->stop($files, $errors, $verbose);
 }