Browse Source

modified AutoloadBuilder for test exclusion

master
Anton Grebnev 13 years ago
parent
commit
6aab56c814
  1. 15
      util/AutoloadBuilder.php

15
util/AutoloadBuilder.php

@ -17,8 +17,11 @@
class AutoloadBuilder
{
protected $autoload;
protected $dirs;
protected $handler;
protected $regex = '/(class|interface) ([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/';
public function __construct($autoload, $dirs = array())
@ -41,7 +44,7 @@ class AutoloadBuilder
foreach ($iterator as $file) {
// skip non php files
$e = explode('.', $file->getFileName());
if ((end($e) !== 'php') || strstr($file->getFileName(), 'test')) {
if ((end($e) !== 'php') || $this->rightSubstr($file->getFileName(), 8) == 'Test.php') {
continue;
}
@ -79,11 +82,17 @@ class AutoloadBuilder
protected function write($string)
{
if (! $this->handler) {
if (! $this->handler = fopen($this->autoload, 'w')) {
if (!$this->handler) {
if (!$this->handler = fopen($this->autoload, 'w')) {
trigger_error("{$this->autoload} is not writable", E_USER_ERROR);
}
}
return (bool) fwrite($this->handler, $string);
}
protected function rightSubstr($string, $nchars)
{
$right = substr($string, strlen($string) - $nchars, $nchars);
return $right;
}
}
Loading…
Cancel
Save