\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /opt/cpanel/ea-wappspector/vendor/squizlabs/php_codesniffer/src/Files/

Viewing File: FileList.php

<?php
/**
 * Represents a list of files on the file system that are to be checked during the run.
 *
 * File objects are created as needed rather than all at once.
 *
 * @author    Greg Sherwood <gsherwood@squiz.net>
 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
 * @license   https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence
 */

namespace PHP_CodeSniffer\Files;

use Countable;
use FilesystemIterator;
use Iterator;
use PHP_CodeSniffer\Autoload;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Exceptions\DeepExitException;
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Util\Common;
use RecursiveArrayIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ReturnTypeWillChange;

class FileList implements Iterator, Countable
{

    /**
     * A list of file paths that are included in the list.
     *
     * @var array
     */
    private $files = [];

    /**
     * The number of files in the list.
     *
     * @var integer
     */
    private $numFiles = 0;

    /**
     * The config data for the run.
     *
     * @var \PHP_CodeSniffer\Config
     */
    public $config = null;

    /**
     * The ruleset used for the run.
     *
     * @var \PHP_CodeSniffer\Ruleset
     */
    public $ruleset = null;

    /**
     * An array of patterns to use for skipping files.
     *
     * @var array
     */
    protected $ignorePatterns = [];


    /**
     * Constructs a file list and loads in an array of file paths to process.
     *
     * @param \PHP_CodeSniffer\Config  $config  The config data for the run.
     * @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run.
     *
     * @return void
     */
    public function __construct(Config $config, Ruleset $ruleset)
    {
        $this->ruleset = $ruleset;
        $this->config  = $config;

        $paths = $config->files;
        foreach ($paths as $path) {
            $isPharFile = Common::isPharFile($path);
            if (is_dir($path) === true || $isPharFile === true) {
                if ($isPharFile === true) {
                    $path = 'phar://'.$path;
                }

                $filterClass = $this->getFilterClass();

                $di       = new RecursiveDirectoryIterator($path, (RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS));
                $filter   = new $filterClass($di, $path, $config, $ruleset);
                $iterator = new RecursiveIteratorIterator($filter);

                foreach ($iterator as $file) {
                    $this->files[$file->getPathname()] = null;
                }
            } else {
                $this->addFile($path);
            }//end if
        }//end foreach

        reset($this->files);
        $this->numFiles = count($this->files);

    }//end __construct()


    /**
     * Add a file to the list.
     *
     * If a file object has already been created, it can be passed here.
     * If it is left NULL, it will be created when accessed.
     *
     * @param string                           $path The path to the file being added.
     * @param \PHP_CodeSniffer\Files\File|null $file The file being added.
     *
     * @return void
     */
    public function addFile($path, $file=null)
    {
        // No filtering is done for STDIN when the filename
        // has not been specified.
        if ($path === 'STDIN') {
            $this->files[$path] = $file;
            $this->numFiles++;
            return;
        }

        $filterClass = $this->getFilterClass();

        $di       = new RecursiveArrayIterator([$path]);
        $filter   = new $filterClass($di, $path, $this->config, $this->ruleset);
        $iterator = new RecursiveIteratorIterator($filter);

        foreach ($iterator as $path) {
            if (array_key_exists($path, $this->files) === true) {
                // The path has already been added.
                continue;
            }

            $this->files[$path] = $file;
            $this->numFiles++;
        }

    }//end addFile()


    /**
     * Get the class name of the filter being used for the run.
     *
     * @return string
     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the specified filter could not be found.
     */
    private function getFilterClass()
    {
        $filterType = $this->config->filter;

        if ($filterType === null) {
            $filterClass = '\PHP_CodeSniffer\Filters\Filter';
        } else {
            if (strpos($filterType, '.') !== false) {
                // This is a path to a custom filter class.
                $filename = realpath($filterType);
                if ($filename === false) {
                    $error = "ERROR: Custom filter \"$filterType\" not found".PHP_EOL;
                    throw new DeepExitException($error, 3);
                }

                $filterClass = Autoload::loadFile($filename);
            } else {
                $filterClass = '\PHP_CodeSniffer\Filters\\'.$filterType;
            }
        }

        return $filterClass;

    }//end getFilterClass()


    /**
     * Rewind the iterator to the first file.
     *
     * @return void
     */
    #[ReturnTypeWillChange]
    public function rewind()
    {
        reset($this->files);

    }//end rewind()


    /**
     * Get the file that is currently being processed.
     *
     * @return \PHP_CodeSniffer\Files\File
     */
    #[ReturnTypeWillChange]
    public function current()
    {
        $path = key($this->files);
        if (isset($this->files[$path]) === false) {
            $this->files[$path] = new LocalFile($path, $this->ruleset, $this->config);
        }

        return $this->files[$path];

    }//end current()


    /**
     * Return the file path of the current file being processed.
     *
     * @return string|null Path name or `null` when the end of the iterator has been reached.
     */
    #[ReturnTypeWillChange]
    public function key()
    {
        return key($this->files);

    }//end key()


    /**
     * Move forward to the next file.
     *
     * @return void
     */
    #[ReturnTypeWillChange]
    public function next()
    {
        next($this->files);

    }//end next()


    /**
     * Checks if current position is valid.
     *
     * @return boolean
     */
    #[ReturnTypeWillChange]
    public function valid()
    {
        if (current($this->files) === false) {
            return false;
        }

        return true;

    }//end valid()


    /**
     * Return the number of files in the list.
     *
     * @return integer
     */
    #[ReturnTypeWillChange]
    public function count()
    {
        return $this->numFiles;

    }//end count()


}//end class