Code refactoring, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@115 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -11,6 +11,9 @@
|
||||
* @filesource $URL$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo Refactoring writing, locking
|
||||
*/
|
||||
class AutoloadBuilder
|
||||
{
|
||||
protected $autoload;
|
||||
@ -27,7 +30,6 @@ class AutoloadBuilder
|
||||
public function build()
|
||||
{
|
||||
$this->openAutoload();
|
||||
echo "parsing started...\n";
|
||||
// for dublicates check
|
||||
$classes = array();
|
||||
foreach ($this->dirs as $dir) {
|
||||
@ -50,13 +52,9 @@ class AutoloadBuilder
|
||||
|
||||
if (preg_match_all($this->regex, $content, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
echo "found {$match[0]}...";
|
||||
if (array_key_exists($match[2], $classes)) {
|
||||
echo " FAULT\n{$match[0]} also found in ".
|
||||
$file->getRealPath(). ", skipped.\n";
|
||||
continue;
|
||||
}
|
||||
echo " OK\n";
|
||||
$string = "'{$match[2]}'=>'" . $relative_path . "',\n";
|
||||
$this->write($string);
|
||||
$classes[$match[2]] = $file->getRealPath();
|
||||
@ -64,7 +62,6 @@ class AutoloadBuilder
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "done.\n";
|
||||
$this->closeAutoload();
|
||||
}
|
||||
|
||||
@ -75,7 +72,7 @@ class AutoloadBuilder
|
||||
|
||||
protected function closeAutoload()
|
||||
{
|
||||
if ($this->write(");\n")) {
|
||||
if ($this->write(');')) {
|
||||
fclose($this->handler);
|
||||
}
|
||||
}
|
||||
@ -84,11 +81,9 @@ class AutoloadBuilder
|
||||
{
|
||||
if (! $this->handler) {
|
||||
if (! $this->handler = fopen($this->autoload, 'w')) {
|
||||
echo "{$this->autoload} is not writable\n";
|
||||
die;
|
||||
trigger_error("{$this->autoload} is not writable", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
return (bool) fwrite($this->handler, $string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user