Example #1
0
 /**
  * Загружает глобальные настройки из файла и кеширует их в массиве GLOBALS.
  * Данный метод вызывается ТОЛЬКО при создании экземпляра класса.
  */
 private function load()
 {
     check_condition(!is_array($this->GLOBALS), 'Недопустима повторная загрузка глобальных настроек');
     $this->GLOBALS = array();
     $this->FileMtimeUpdate();
     $comment = array();
     foreach ($this->DI->getFileLines() as $line) {
         $line = trim($line);
         if (!$line || starts_with($line, '/*') || ends_with($line, '*/')) {
             continue;
         }
         if (starts_with($line, '*')) {
             $line = trim(first_char_remove($line));
             if ($line) {
                 $comment[] = $line;
             }
             continue;
         }
         if (starts_with($line, 'define')) {
             $name = trim(array_get_value(1, explode("'", $line, 3)));
             check_condition($name && defined($name), "Ошибка разбора файла глобальных настроек: свойство [{$name}] не определено.");
             $this->GLOBALS[$name] = new PsGlobalProp($name, implode(' ', $comment));
             $comment = array();
             continue;
         }
     }
 }
Example #2
0
 /**
  * Возвращает тело класса/интерфейса
  */
 public function getClassBody()
 {
     $lines = $this->di->getFileLines(true, true);
     $firstLine = $this->rc->getStartLine();
     $endLine = $this->rc->getEndLine();
     if ($endLine <= $firstLine + 1) {
         return '';
     }
     return trim(implode('', array_slice($lines, $firstLine, $endLine - $firstLine - 1)));
 }
Example #3
0
 /**
  * Парсит файл профайлинга и возвращает массив вида:
  * ident=>Secundomer
  * Идентификатор здесь, это идентификатор профилируемой сущности, например - текст запроса.
  */
 private function parseProfiler(DirItem $file)
 {
     $result = array();
     $lines = $file->getFileLines(false);
     if (empty($lines)) {
         return $result;
         //---
     }
     foreach ($lines as $line) {
         $tokens = explode('|', $line);
         if (count($tokens) != 3) {
             continue;
         }
         $ident = trim($tokens[0]);
         $count = trim($tokens[1]);
         $time = trim($tokens[2]);
         if (!$ident || !is_numeric($count) || !is_numeric($time)) {
             continue;
         }
         if (!array_key_exists($ident, $result)) {
             $result[$ident] = Secundomer::inst();
         }
         $result[$ident]->add($count, $time);
     }
     return $result;
 }
Example #4
0
 protected function onInit(DirItem $di)
 {
     $this->lines = to_array($di->getFileLines(false));
 }