Source for file ExactMatch.php
Documentation is available at ExactMatch.php
* An abstract filter class for checking files and folders against exact matches.
* Supports both whitelists and blacklists.
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
namespace PHP_CodeSniffer\Filters;
use PHP_CodeSniffer\Util;
abstract class ExactMatch extends Filter
* A list of files to exclude.
private $blacklist = null;
* A list of files to include.
* If the whitelist is empty, only files in the blacklist will be excluded.
private $whitelist = null;
* Check whether the current element of the iterator is acceptable.
* If a file is both blacklisted and whitelisted, it will be deemed unacceptable.
if (parent ::accept () === false ) {
if ($this->blacklist === null ) {
$this->blacklist = $this->getblacklist ();
if ($this->whitelist === null ) {
$this->whitelist = $this->getwhitelist ();
$filePath = Util\Common ::realpath ($this->current ());
// If file is both blacklisted and whitelisted, the blacklist takes precedence.
if (isset ($this->blacklist[$filePath]) === true ) {
if (empty ($this->whitelist) === true && empty ($this->blacklist) === false ) {
// We are only checking a blacklist, so everything else should be whitelisted.
return isset ($this->whitelist[$filePath]);
* Returns an iterator for the current entry.
* Ensures that the blacklist and whitelist are preserved so they don't have
* to be generated each time.
* @return \RecursiveIterator
public function getChildren ()
$children = parent ::getChildren ();
$children->blacklist = $this->blacklist;
$children->whitelist = $this->whitelist;
* Get a list of blacklisted file paths.
abstract protected function getBlacklist ();
* Get a list of whitelisted file paths.
abstract protected function getWhitelist ();
Documentation generated on Mon, 11 Mar 2019 15:27:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|