Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/browser-kit/History.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
16 * | 16 * |
17 * @author Fabien Potencier <fabien@symfony.com> | 17 * @author Fabien Potencier <fabien@symfony.com> |
18 */ | 18 */ |
19 class History | 19 class History |
20 { | 20 { |
21 protected $stack = array(); | 21 protected $stack = []; |
22 protected $position = -1; | 22 protected $position = -1; |
23 | 23 |
24 /** | 24 /** |
25 * Clears the history. | 25 * Clears the history. |
26 */ | 26 */ |
27 public function clear() | 27 public function clear() |
28 { | 28 { |
29 $this->stack = array(); | 29 $this->stack = []; |
30 $this->position = -1; | 30 $this->position = -1; |
31 } | 31 } |
32 | 32 |
33 /** | 33 /** |
34 * Adds a Request to the history. | 34 * Adds a Request to the history. |
35 */ | 35 */ |
36 public function add(Request $request) | 36 public function add(Request $request) |
37 { | 37 { |
38 $this->stack = array_slice($this->stack, 0, $this->position + 1); | 38 $this->stack = \array_slice($this->stack, 0, $this->position + 1); |
39 $this->stack[] = clone $request; | 39 $this->stack[] = clone $request; |
40 $this->position = count($this->stack) - 1; | 40 $this->position = \count($this->stack) - 1; |
41 } | 41 } |
42 | 42 |
43 /** | 43 /** |
44 * Returns true if the history is empty. | 44 * Returns true if the history is empty. |
45 * | 45 * |
46 * @return bool true if the history is empty, false otherwise | 46 * @return bool true if the history is empty, false otherwise |
47 */ | 47 */ |
48 public function isEmpty() | 48 public function isEmpty() |
49 { | 49 { |
50 return 0 == count($this->stack); | 50 return 0 == \count($this->stack); |
51 } | 51 } |
52 | 52 |
53 /** | 53 /** |
54 * Goes back in the history. | 54 * Goes back in the history. |
55 * | 55 * |
73 * | 73 * |
74 * @throws \LogicException if the stack is already on the last page | 74 * @throws \LogicException if the stack is already on the last page |
75 */ | 75 */ |
76 public function forward() | 76 public function forward() |
77 { | 77 { |
78 if ($this->position > count($this->stack) - 2) { | 78 if ($this->position > \count($this->stack) - 2) { |
79 throw new \LogicException('You are already on the last page.'); | 79 throw new \LogicException('You are already on the last page.'); |
80 } | 80 } |
81 | 81 |
82 return clone $this->stack[++$this->position]; | 82 return clone $this->stack[++$this->position]; |
83 } | 83 } |