public function addBlocks($blocks) { foreach ($blocks as $name => $block) { if (isset($this->blocks[$name])) { py_arr_insert($this->blocks[$name], 0, $block); } else { $this->blocks[$name] = array($block); } } }
public function testArrInsert() { $empty_arr = array(); py_arr_insert($empty_arr, 0, 'first'); $this->assertEquals($empty_arr, array('first')); $input_arr = array('second', 'fourth'); py_arr_insert($input_arr, 0, 'first'); $this->assertEquals($input_arr, array('first', 'second', 'fourth')); py_arr_insert($input_arr, 2, 'third'); $this->assertEquals($input_arr, array('first', 'second', 'third', 'fourth')); }
/** * @param Token $token */ public function prependToken($token) { py_arr_insert($this->tokens, 0, $token); }