1 | <?php |
||
7 | class Stack extends \SplDoublyLinkedList implements StackInterface |
||
8 | { |
||
9 | 580 | public function __construct() |
|
13 | |||
14 | 32 | public function bottom() |
|
18 | |||
19 | /** |
||
20 | * @param BufferInterface $value |
||
21 | * @throws \InvalidArgumentException |
||
22 | */ |
||
23 | 28 | private function typeCheck($value) |
|
29 | |||
30 | /** |
||
31 | * @see \ArrayAccess::offsetGet() |
||
32 | * @param int $offset |
||
33 | * @return \BitWasp\Buffertools\BufferInterface |
||
34 | */ |
||
35 | 368 | public function offsetGet($offset) |
|
40 | |||
41 | /** |
||
42 | * @see \ArrayAccess::offsetSet() |
||
43 | * @param int $offset |
||
44 | * @param BufferInterface $value |
||
45 | * @throws \InvalidArgumentException |
||
46 | */ |
||
47 | 16 | public function offsetSet($offset, $value) |
|
53 | |||
54 | /** |
||
55 | * @see \ArrayAccess::offsetExists() |
||
56 | * @param int $offset |
||
57 | * @return bool |
||
58 | */ |
||
59 | 4 | public function offsetExists($offset) |
|
64 | |||
65 | /** |
||
66 | * @see \ArrayAccess::offsetUnset() |
||
67 | * @param int $offset |
||
68 | */ |
||
69 | 24 | public function offsetUnset($offset) |
|
74 | |||
75 | /** |
||
76 | * @param int $first |
||
77 | * @param int $second |
||
78 | */ |
||
79 | 16 | public function swap($first, $second) |
|
86 | |||
87 | /** |
||
88 | * @param int $index |
||
89 | * @param BufferInterface $value |
||
90 | */ |
||
91 | 12 | public function add($index, $value) |
|
92 | { |
||
93 | 12 | $this->typeCheck($value); |
|
94 | |||
95 | 12 | if (getenv('HHVM_VERSION') || version_compare(phpversion(), '5.5.0', 'lt')) { |
|
96 | if ($index == $this->count()) { |
||
97 | $this->push($value); |
||
98 | } else { |
||
99 | $size = count($this); |
||
100 | $temp = []; |
||
101 | for ($i = $size; $i > $index; $i--) { |
||
102 | array_unshift($temp, $this->pop()); |
||
103 | } |
||
104 | |||
105 | $this->push($value); |
||
106 | foreach ($temp as $value) { |
||
107 | $this->push($value); |
||
108 | } |
||
109 | } |
||
110 | } else { |
||
111 | 12 | parent::add($index, $value); |
|
112 | } |
||
113 | 8 | } |
|
114 | |||
115 | /** |
||
116 | * @return int |
||
117 | */ |
||
118 | 540 | public function end() |
|
127 | |||
128 | /** |
||
129 | * @param int $length |
||
130 | * @return $this |
||
131 | */ |
||
132 | 20 | public function resize($length) |
|
144 | } |
||
145 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.