Executes Twig validator against a list of files, if in twig.filesets.

@command tests:twig:lint:files
@aliases ttlf

@param string $file_list
A list of files to scan, separated by \n.
978756
public function lintFileList($file_list) {
    $this->say("Linting twig files...");

    $files = explode("\n", $file_list);

    /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */
    $fileset_manager = $this->getContainer()->get('filesetManager');
    $fileset_ids = $this->getConfigValue('validate.twig.filesets');
    $filesets = $fileset_manager->getFilesets($fileset_ids, TRUE);
    foreach ($filesets as $fileset_id => $fileset) {
      $filesets[$fileset_id] = $fileset_manager->filterFilesByFileset($files, $fileset);
    }
    $this->executeTwigLintCommandAgainstFilesets($filesets);
  }
786213
protected function _validateItem()
    {
        if ($this->valid()) {
            if ($this->hasChildren() && $this->getDirectoryValidationCallback()) {
                $this->_validate($this->getDirectoryValidationCallback());
            } elseif (is_file($this->getRealPath()) && $this->getFileValidationCallback()) {
                $this->_validate($this->getFileValidationCallback());
            }
        }
    }
344495
protected function _checkForFiles($method_template, $key, $value) {
    if (!array_key_exists($method_template, self::$_possible_files)
      || !in_array($key, self::$_possible_files[$method_template])
    ) {
      return false;
    }
    $data = $this->_buildBinaryBody($value);
    if ($data === $value) {
      return false;
    }
    return $data;
  }
1179808
public function iRunPhpDocumentorAgainstTheFile($file_path)
    {
        $tmp = self::getTmpFolder();
        $fullPath = __DIR__ . '/../../' . $file_path;
        $this->iRunPhpdoc("-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force");
    }
101425
public function list_files() {
        $this->listresults = array();
        $this->mode = self::MODE_LIST;
        $this->extract_or_list();
        $listresults = $this->listresults;
        $this->listresults = null;
        return $listresults;
    }
1217919
public function shouldLoadFile($file_name)
    {
        $whitelisted_files = $this->whitelisted_files;
        if ($whitelisted_files === null) return true;
        if (!(in_array($file_name, $whitelisted_files) ||
                array_key_exists($file_name, $whitelisted_files))) {
            return false;
        }
        return true;
    }
1216014
public static function listFiles($code_dir, $pattern = '/\.php$/')
    {
        $flags = FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS;
        $dir_iter = new RecursiveDirectoryIterator($code_dir, $flags);
        $iter_iter = new RecursiveIteratorIterator($dir_iter);
        return new RegexIterator($iter_iter, $pattern);
    }
786451
def files_inspected(ext, delimiter = ',', remove = @config.working_dir)
        @path.is_a?(Array) ? @path.split(delimiter) : file_list(@path, ext, remove)
      end
731777
private function scanTwigFiles()
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.twig')
            ->notName('*~')
            ->exclude(['cache', 'config', 'database', 'resources', 'tests', 'bower_components', 'node_modules'])
            ->in($this->app['path_resolver']->resolve('themes'))
            ->in($this->app['path_resolver']->resolve('app')); // yes, app = bad. Will be refactored in 3.4

        // Regex from: stackoverflow.com/questions/5695240/php-regex-to-ignore-escaped-quotes-within-quotes
        $twigRegex = [
            "/\b__\(\s*'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'(?U).*\)/s" => ['\\\'' => '\''], // __('single_quoted_string'…
            '/\b__\(\s*"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?U).*\)/s' => ['\"'   => '"'], // __("double_quoted_string"…
        ];

        foreach ($finder as $file) {
            /** @var \Symfony\Component\Finder\SplFileInfo $file */
            foreach ($twigRegex as $regex => $stripslashes) {
                if (preg_match_all($regex, $file->getContents(), $matches)) {
                    foreach ($matches[1] as $foundString) {
                        $this->addTranslatable(strtr($foundString, $stripslashes));
                    }
                }
            }
        }
    }
1287145
public static function checkPatternMatchFileList($fileList, $pattern){
		foreach ($fileList as $filename) {
			if(self::checkFilePattern($filename, $pattern))
				return true;
		}
		return false;
	}
2191
public function validateSortField(SS_List $list)
    {
        $field = $this->getSortField();

        // Check extra fields on many many relation types
        if ($list instanceof ManyManyList) {
            $extra = $list->getExtraFields();

            if ($extra && array_key_exists($field, $extra)) {
                return;
            }
        } elseif ($list instanceof ManyManyThroughList) {
            $manipulator = $this->getManyManyInspector($list);
            $fieldTable = DataObject::getSchema()->tableForField($manipulator->getJoinClass(), $field);
            if ($fieldTable) {
                return;
            }
        }

        $classes = ClassInfo::dataClassesFor($list->dataClass());

        foreach ($classes as $class) {
            if (singleton($class)->hasDataBaseField($field)) {
                return;
            }
        }

        throw new Exception("Couldn't find the sort field '" . $field . "'");
    }
903414
private function _checkFile($fileInfo)
    {
        $result = isset($fileInfo['name']) && isset($fileInfo['tmp_name']);

        if ($result && isset($fileInfo['error']) && $fileInfo['error']) {
            $result = false;
        }

        return $result;
    }
1090540
public function create(ListCollection $list, $ttl = null, $chunkSize = null)
    {
        // check if list already exists in memory
        $listUuid = (string) $list->getUuid();
        if ($this->existsListInIndex($listUuid) && $this->exists($listUuid)) {
            throw new ListAlreadyExistsException('List '.$list->getUuid().' already exists in memory.');
        }

        if (!$chunkSize && !is_int($chunkSize)) {
            $chunkSize = self::CHUNKSIZE;
        }

        // create arrayOfElements
        $arrayOfElements = [];

        /** @var ListElement $element */
        foreach ($list->getElements() as $element) {
            $arrayOfElements[(string) $element->getUuid()] = $element->getBody();
        }

        // persist in memory array in chunks
        $arrayChunks = array_chunk($arrayOfElements, $chunkSize, true);
        foreach ($arrayChunks as $chunkNumber => $item) {
            $arrayToPersist = [];
            foreach ($item as $key => $element) {
                $arrayToPersist[$key] = $element;
            }

            $this->memcached->set(
                (string) $list->getUuid().self::SEPARATOR.'chunk-'.($chunkNumber + 1),
                $arrayToPersist,
                $ttl
            );
        }

        // set headers
        if ($list->getHeaders()) {
            $this->memcached->set(
                (string) $list->getUuid().self::SEPARATOR.self::HEADERS,
                $list->getHeaders(),
                $ttl
            );
        }

        // add list to index
        $this->addOrUpdateListToIndex(
            $listUuid,
            (int) count($list->getElements()),
            (int) count($arrayChunks),
            (int) $chunkSize,
            $ttl
        );
    }
478577
private void listFiles(File dir, List<File> results) {
        File[] found = dir.listFiles();
        if ( found != null ) {
            for ( File f : found ) {
                if (f.isDirectory()) {
                	//do nothing
                } else {
                    results.add(f);
                }
            }
        }
    }
700881
protected function executeTwigLintCommandAgainstFilesets(array $filesets) {
    $command = $this->createTwigLintCommand();

    /** @var \Acquia\Blt\Robo\Application $application */
    $application = $this->getContainer()->get('application');
    $application->add($command);

    $passed = TRUE;
    $failed_filesets = [];
    foreach ($filesets as $fileset_id => $fileset) {
      if (!is_null($fileset) && iterator_count($fileset)) {
        $this->say("Iterating over fileset $fileset_id...");
        $files = iterator_to_array($fileset);
        $input = new ArrayInput(['filename' => $files]);
        $exit_code = $application->runCommand($command, $input, $this->output());
        if ($exit_code) {
          // We iterate over all filesets before throwing an exception.
          $passed = FALSE;
          $failed_filesets[] = $fileset_id;
        }
      }
      else {
        $this->logger->info("No files were found in fileset $fileset_id. Skipped.");
      }
    }

    if (!$passed) {
      throw new BltException("Linting twig against fileset(s) " . implode(', ', $failed_filesets) . " returned a non-zero exit code.`");
    }

    // If exception wasn't thrown, checks were successful.
    $this->say("All Twig files contain valid syntax.");
  }
120414
private static function validation()
    {
        $files = ['Validator', 'ValidationResult'];
        $folder = static::$root.'Validation'.'/';

        self::call($files, $folder);

        //Initiate the validation surface
        Validator::ini();
    }
1110702
public function lintFileSets() {
    $this->say("Validating yaml syntax for all custom modules and exported config...");

    /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */
    $fileset_manager = $this->getContainer()->get('filesetManager');
    $fileset_ids = $this->getConfigValue('validate.yaml.filesets');
    $filesets = $fileset_manager->getFilesets($fileset_ids, TRUE);
    $bin = $this->getConfigValue('composer.bin');
    $command = "'$bin/yaml-cli' lint '%s'";
    $this->executeCommandAgainstFilesets($filesets, $command, TRUE);
  }