9 class autoloaderIgnoreDotD
extends \FilterIterator
11 private $_ignoreGlobList =
false;
13 public function accept()
15 $c = $this->current()->getPathname();
17 if (substr(
$c, -4) !=
'.php')
return false;
18 if (preg_match(
'/^Method/', basename(
$c)))
return false;
20 if ($this->_inAutoloaderIgnore(
$c))
return false;
22 return is_readable(
$c);
31 private function _inAutoloaderIgnore($fileName)
33 if ($this->_ignoreGlobList ===
false) {
34 $this->_ignoreGlobList = $this->_parseAutoloaderIgnoreDotD();
36 if (strpos($fileName,
'./') === 0) {
37 $fileName = substr($fileName, 2);
39 foreach ($this->_ignoreGlobList as $glob) {
40 if (fnmatch($glob, $fileName)) {
53 private function _parseAutoloaderIgnoreFile($ignoreFile)
55 $globList = file($ignoreFile);
56 if ($globList ===
false) {
57 throw new DirectoriesAutoloaderException(sprintf(
"Error opening autoloader ignore file '%s'.", $ignoreFile));
59 $globList = array_filter(array_map(
function ($e)
62 return rtrim($e,
"\r\n");
64 , $globList) ,
function ($e)
67 return !preg_match(
'/^\s*(#.*)?$/', $e);
69 $globList = array_map(
function ($e)
75 if (strpos($e,
'./') === 0) {
89 private function _parseAutoloaderIgnoreDotD()
93 $dir = $pubdir . DIRECTORY_SEPARATOR .
'.autoloader-ignore.d';
99 throw new DirectoriesAutoloaderException(sprintf(
"Error opening '.autoloader-ignore.d' directory '%s'.",
$dir));
101 while ((
$file = readdir($dh)) !==
false) {
105 $globList = array_merge($globList, $this->_parseAutoloaderIgnoreFile(
$dir . DIRECTORY_SEPARATOR .
$file));