예제 #1
0
 /**
  * Internal method used by compile(). Handle exists error and return error status.
  *
  * @param array $context Current context of compiler progress.
  *
  * @throws Exception
  * @return boolean True when error detected
  *
  * @expect true when input Array('level' => 1, 'stack' => Array('X'), 'flags' => Array('errorlog' => 0, 'exception' => 0), 'error' => Array())
  * @expect false when input Array('level' => 0, 'error' => Array())
  * @expect true when input Array('level' => 0, 'error' => Array('some error'), 'flags' => Array('errorlog' => 0, 'exception' => 0))
  */
 protected static function handleError(&$context)
 {
     if ($context['level'] !== 0) {
         $token = array_pop($context['stack']);
         $context['error'][] = "Unclosed token {{{#{$token}}}} !!";
     }
     self::$lastContext = $context;
     if (count($context['error'])) {
         if ($context['flags']['errorlog']) {
             error_log(implode("\n", $context['error']));
         }
         if ($context['flags']['exception']) {
             throw new Exception(implode("\n", $context['error']));
         }
         return true;
     }
     return false;
 }