Browse Source

modified AutoloadBuilder for test exclusion

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

21
util/AutoloadBuilder.php

@ -17,14 +17,17 @@
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())
{
$this->autoload = $autoload;
$this->dirs = $dirs;
$this->dirs = $dirs;
}
public function build()
@ -41,9 +44,9 @@ class AutoloadBuilder
foreach ($iterator as $file) {
// skip non php files
$e = explode('.', $file->getFileName());
if ((end($e) !== 'php') || strstr($file->getFileName(), 'test')) {
continue;
}
if ((end($e) !== 'php') || $this->rightSubstr($file->getFileName(), 8) == 'Test.php') {
continue;
}
$content = file_get_contents($file->getRealPath());
$matches = array();
@ -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