Skip to content

Filters/ExactMatch: rename some private properties #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/Filters/ExactMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* An abstract filter class for checking files and folders against exact matches.
*
* Supports both whitelists and blacklists.
* Supports both allowed files and blocked files.
*
* @author Greg Sherwood <[email protected]>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -21,22 +21,22 @@ abstract class ExactMatch extends Filter
*
* @var array
*/
private $blacklist = null;
private $blockedFiles = null;

/**
* A list of files to include.
*
* If the whitelist is empty, only files in the blacklist will be excluded.
* If the allowed files list is empty, only files in the blocked files list will be excluded.
*
* @var array
*/
private $whitelist = null;
private $allowedFiles = 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 a file is both blocked and allowed, it will be deemed unacceptable.
*
* @return bool
*/
Expand All @@ -46,59 +46,59 @@ public function accept()
return false;
}

if ($this->blacklist === null) {
$this->blacklist = $this->getblacklist();
if ($this->blockedFiles === null) {
$this->blockedFiles = $this->getblacklist();
}

if ($this->whitelist === null) {
$this->whitelist = $this->getwhitelist();
if ($this->allowedFiles === null) {
$this->allowedFiles = $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 file is both blocked and allowed, the blocked files list takes precedence.
if (isset($this->blockedFiles[$filePath]) === true) {
return false;
}

if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
// We are only checking a blacklist, so everything else should be whitelisted.
if (empty($this->allowedFiles) === true && empty($this->blockedFiles) === false) {
// We are only checking a blocked files list, so everything else should be allowed.
return true;
}

return isset($this->whitelist[$filePath]);
return isset($this->allowedFiles[$filePath]);

}//end accept()


/**
* Returns an iterator for the current entry.
*
* Ensures that the blacklist and whitelist are preserved so they don't have
* Ensures that the blocked files list and the allowed files list 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;
$children = parent::getChildren();
$children->blockedFiles = $this->blockedFiles;
$children->allowedFiles = $this->allowedFiles;
return $children;

}//end getChildren()


/**
* Get a list of blacklisted file paths.
* Get a list of file paths to exclude.
*
* @return array
*/
abstract protected function getBlacklist();


/**
* Get a list of whitelisted file paths.
* Get a list of file paths to include.
*
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/GitModified.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GitModified extends ExactMatch


/**
* Get a list of blacklisted file paths.
* Get a list of file paths to exclude.
*
* @return array
*/
Expand All @@ -28,7 +28,7 @@ protected function getBlacklist()


/**
* Get a list of whitelisted file paths.
* Get a list of file paths to include.
*
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Filters/GitStaged.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GitStaged extends ExactMatch


/**
* Get a list of blacklisted file paths.
* Get a list of file paths to exclude.
*
* @return array
*/
Expand All @@ -30,7 +30,7 @@ protected function getBlacklist()


/**
* Get a list of whitelisted file paths.
* Get a list of file paths to include.
*
* @return array
*/
Expand Down