1 | <?php |
||
35 | abstract class GenericArrayObject extends ArrayObject { |
||
36 | /** |
||
37 | * Returns the name of an interface/class that the element should implement/extend. |
||
38 | * |
||
39 | * @since 1.20 |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | abstract public function getObjectType(); |
||
44 | |||
45 | /** |
||
46 | * @see SiteList::getNewOffset() |
||
47 | * @since 1.20 |
||
48 | * @var integer |
||
49 | */ |
||
50 | protected $indexOffset = 0; |
||
51 | |||
52 | /** |
||
53 | * Finds a new offset for when appending an element. |
||
54 | * The base class does this, so it would be better to integrate, |
||
55 | * but there does not appear to be any way to do this... |
||
56 | * |
||
57 | * @since 1.20 |
||
58 | * |
||
59 | * @return integer |
||
60 | */ |
||
61 | protected function getNewOffset() { |
||
68 | |||
69 | /** |
||
70 | * Constructor. |
||
71 | * @see ArrayObject::__construct |
||
72 | * |
||
73 | * @since 1.20 |
||
74 | * |
||
75 | * @param null|array $input |
||
76 | * @param int $flags |
||
77 | * @param string $iterator_class |
||
78 | */ |
||
79 | public function __construct( $input = null, $flags = 0, $iterator_class = 'ArrayIterator' ) { |
||
88 | |||
89 | /** |
||
90 | * @see ArrayObject::append |
||
91 | * |
||
92 | * @since 1.20 |
||
93 | * |
||
94 | * @param mixed $value |
||
95 | */ |
||
96 | public function append( $value ) { |
||
99 | |||
100 | /** |
||
101 | * @see ArrayObject::offsetSet() |
||
102 | * |
||
103 | * @since 1.20 |
||
104 | * |
||
105 | * @param mixed $index |
||
106 | * @param mixed $value |
||
107 | */ |
||
108 | public function offsetSet( $index, $value ) { |
||
111 | |||
112 | /** |
||
113 | * Returns if the provided value has the same type as the elements |
||
114 | * that can be added to this ArrayObject. |
||
115 | * |
||
116 | * @since 1.20 |
||
117 | * |
||
118 | * @param mixed $value |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | protected function hasValidType( $value ) { |
||
126 | |||
127 | /** |
||
128 | * Method that actually sets the element and holds |
||
129 | * all common code needed for set operations, including |
||
130 | * type checking and offset resolving. |
||
131 | * |
||
132 | * If you want to do additional indexing or have code that |
||
133 | * otherwise needs to be executed whenever an element is added, |
||
134 | * you can overload @see preSetElement. |
||
135 | * |
||
136 | * @since 1.20 |
||
137 | * |
||
138 | * @param mixed $index |
||
139 | * @param mixed $value |
||
140 | * |
||
141 | * @throws InvalidArgumentException |
||
142 | */ |
||
143 | protected function setElement( $index, $value ) { |
||
159 | |||
160 | /** |
||
161 | * Gets called before a new element is added to the ArrayObject. |
||
162 | * |
||
163 | * At this point the index is always set (ie not null) and the |
||
164 | * value is always of the type returned by @see getObjectType. |
||
165 | * |
||
166 | * Should return a boolean. When false is returned the element |
||
167 | * does not get added to the ArrayObject. |
||
168 | * |
||
169 | * @since 1.20 |
||
170 | * |
||
171 | * @param integer|string $index |
||
172 | * @param mixed $value |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | protected function preSetElement( $index, $value ) { |
||
179 | |||
180 | /** |
||
181 | * @see Serializable::serialize |
||
182 | * |
||
183 | * @since 1.20 |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | public function serialize() { |
||
190 | |||
191 | /** |
||
192 | * Returns an array holding all the data that should go into serialization calls. |
||
193 | * This is intended to allow overloading without having to reimplement the |
||
194 | * behavior of this base class. |
||
195 | * |
||
196 | * @since 1.20 |
||
197 | * |
||
198 | * @return array |
||
199 | */ |
||
200 | protected function getSerializationData() { |
||
206 | |||
207 | /** |
||
208 | * @see Serializable::unserialize |
||
209 | * |
||
210 | * @since 1.20 |
||
211 | * |
||
212 | * @param string $serialization |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | public function unserialize( $serialization ) { |
||
229 | |||
230 | /** |
||
231 | * Returns if the ArrayObject has no elements. |
||
232 | * |
||
233 | * @since 1.20 |
||
234 | * |
||
235 | * @return bool |
||
236 | */ |
||
237 | public function isEmpty() { |
||
240 | } |
||
241 |
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.