public function pop() { if (count($this->dicts) == 1) { throw new ContextPopException(); } return py_arr_pop($this->dicts); }
public function pop($name) { try { return py_arr_pop($this->blocks[$name]); } catch (KeyError $e) { // IndexError, KeyError return null; } }
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')); }
/** * @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; }
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); }