示例#1
0
文件: context.php 项目: idlesign/dja
 public function pop()
 {
     if (count($this->dicts) == 1) {
         throw new ContextPopException();
     }
     return py_arr_pop($this->dicts);
 }
示例#2
0
 public function pop($name)
 {
     try {
         return py_arr_pop($this->blocks[$name]);
     } catch (KeyError $e) {
         // IndexError, KeyError
         return null;
     }
 }
示例#3
0
 public function testArrPop()
 {
     $input_arr = array('first', 'second', 'third', 'fourth');
     py_arr_pop($input_arr);
     $this->assertEquals($input_arr, array('first', 'second', 'third'));
     py_arr_pop($input_arr, 0);
     $this->assertEquals($input_arr, array('second', 'third'));
     py_arr_pop($input_arr, 1);
     $this->assertEquals($input_arr, array('second'));
 }
示例#4
0
文件: base.php 项目: idlesign/dja
 /**
  * @static
  *
  * @param string $name
  * @param Closure $func
  * @param null|array $provided
  *
  * @return bool
  * @throws TemplateSyntaxError
  */
 public static function argsCheck($name, $func, $provided)
 {
     if (!is_array($provided)) {
         $provided = array($provided);
     }
     $plen = count($provided);
     list($args, $varargs, $varkw, $defaults) = py_inspect_getargspec($func);
     // First argument is filter input.
     py_arr_pop($args, 0);
     if ($defaults) {
         $nondefs = py_slice($args, null, -count($defaults));
     } else {
         $nondefs = $args;
     }
     // Args without defaults must be provided.
     try {
         foreach ($nondefs as $arg) {
             py_arr_pop($provided, 0);
         }
     } catch (IndexError $e) {
         // Not enough
         throw new TemplateSyntaxError($name . ' requires ' . count($nondefs) . ' arguments, ' . $plen . ' provided');
     }
     // Defaults can be overridden.
     try {
         foreach ($provided as $parg) {
             py_arr_pop($defaults, 0);
         }
     } catch (IndexError $e) {
         // Too many.
         throw new TemplateSyntaxError($name . ' requires ' . count($nondefs) . ' arguments, ' . $plen . ' provided');
     }
     return True;
 }
示例#5
0
文件: debug.php 项目: idlesign/dja
 public function unclosedBlockTag($parse_until)
 {
     list($command, $source) = py_arr_pop($this->command_stack);
     $msg = 'Unclosed tag \'' . $command . '\'. Looking for one of: ' . join(', ', $parse_until);
     throw $this->sourceError($source, $msg);
 }