equal
deleted
inserted
replaced
70 * @link https://www.php.net/manual/en/arrayaccess.offsetexists.php |
70 * @link https://www.php.net/manual/en/arrayaccess.offsetexists.php |
71 * |
71 * |
72 * @param string $index Index of block to check. |
72 * @param string $index Index of block to check. |
73 * @return bool Whether block exists. |
73 * @return bool Whether block exists. |
74 */ |
74 */ |
|
75 #[ReturnTypeWillChange] |
75 public function offsetExists( $index ) { |
76 public function offsetExists( $index ) { |
76 return isset( $this->blocks[ $index ] ); |
77 return isset( $this->blocks[ $index ] ); |
77 } |
78 } |
78 |
79 |
79 /** |
80 /** |
84 * @link https://www.php.net/manual/en/arrayaccess.offsetget.php |
85 * @link https://www.php.net/manual/en/arrayaccess.offsetget.php |
85 * |
86 * |
86 * @param string $index Index of block value to retrieve. |
87 * @param string $index Index of block value to retrieve. |
87 * @return mixed|null Block value if exists, or null. |
88 * @return mixed|null Block value if exists, or null. |
88 */ |
89 */ |
|
90 #[ReturnTypeWillChange] |
89 public function offsetGet( $index ) { |
91 public function offsetGet( $index ) { |
90 $block = $this->blocks[ $index ]; |
92 $block = $this->blocks[ $index ]; |
91 |
93 |
92 if ( isset( $block ) && is_array( $block ) ) { |
94 if ( isset( $block ) && is_array( $block ) ) { |
93 $block = new WP_Block( $block, $this->available_context, $this->registry ); |
95 $block = new WP_Block( $block, $this->available_context, $this->registry ); |
105 * @link https://www.php.net/manual/en/arrayaccess.offsetset.php |
107 * @link https://www.php.net/manual/en/arrayaccess.offsetset.php |
106 * |
108 * |
107 * @param string $index Index of block value to set. |
109 * @param string $index Index of block value to set. |
108 * @param mixed $value Block value. |
110 * @param mixed $value Block value. |
109 */ |
111 */ |
|
112 #[ReturnTypeWillChange] |
110 public function offsetSet( $index, $value ) { |
113 public function offsetSet( $index, $value ) { |
111 if ( is_null( $index ) ) { |
114 if ( is_null( $index ) ) { |
112 $this->blocks[] = $value; |
115 $this->blocks[] = $value; |
113 } else { |
116 } else { |
114 $this->blocks[ $index ] = $value; |
117 $this->blocks[ $index ] = $value; |
122 * |
125 * |
123 * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php |
126 * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php |
124 * |
127 * |
125 * @param string $index Index of block value to unset. |
128 * @param string $index Index of block value to unset. |
126 */ |
129 */ |
|
130 #[ReturnTypeWillChange] |
127 public function offsetUnset( $index ) { |
131 public function offsetUnset( $index ) { |
128 unset( $this->blocks[ $index ] ); |
132 unset( $this->blocks[ $index ] ); |
129 } |
133 } |
130 |
134 |
131 /** |
135 /** |
133 * |
137 * |
134 * @since 5.5.0 |
138 * @since 5.5.0 |
135 * |
139 * |
136 * @link https://www.php.net/manual/en/iterator.rewind.php |
140 * @link https://www.php.net/manual/en/iterator.rewind.php |
137 */ |
141 */ |
|
142 #[ReturnTypeWillChange] |
138 public function rewind() { |
143 public function rewind() { |
139 reset( $this->blocks ); |
144 reset( $this->blocks ); |
140 } |
145 } |
141 |
146 |
142 /** |
147 /** |
146 * |
151 * |
147 * @link https://www.php.net/manual/en/iterator.current.php |
152 * @link https://www.php.net/manual/en/iterator.current.php |
148 * |
153 * |
149 * @return mixed Current element. |
154 * @return mixed Current element. |
150 */ |
155 */ |
|
156 #[ReturnTypeWillChange] |
151 public function current() { |
157 public function current() { |
152 return $this->offsetGet( $this->key() ); |
158 return $this->offsetGet( $this->key() ); |
153 } |
159 } |
154 |
160 |
155 /** |
161 /** |
159 * |
165 * |
160 * @link https://www.php.net/manual/en/iterator.key.php |
166 * @link https://www.php.net/manual/en/iterator.key.php |
161 * |
167 * |
162 * @return mixed Key of the current element. |
168 * @return mixed Key of the current element. |
163 */ |
169 */ |
|
170 #[ReturnTypeWillChange] |
164 public function key() { |
171 public function key() { |
165 return key( $this->blocks ); |
172 return key( $this->blocks ); |
166 } |
173 } |
167 |
174 |
168 /** |
175 /** |
170 * |
177 * |
171 * @since 5.5.0 |
178 * @since 5.5.0 |
172 * |
179 * |
173 * @link https://www.php.net/manual/en/iterator.next.php |
180 * @link https://www.php.net/manual/en/iterator.next.php |
174 */ |
181 */ |
|
182 #[ReturnTypeWillChange] |
175 public function next() { |
183 public function next() { |
176 next( $this->blocks ); |
184 next( $this->blocks ); |
177 } |
185 } |
178 |
186 |
179 /** |
187 /** |
181 * |
189 * |
182 * @since 5.5.0 |
190 * @since 5.5.0 |
183 * |
191 * |
184 * @link https://www.php.net/manual/en/iterator.valid.php |
192 * @link https://www.php.net/manual/en/iterator.valid.php |
185 */ |
193 */ |
|
194 #[ReturnTypeWillChange] |
186 public function valid() { |
195 public function valid() { |
187 return null !== key( $this->blocks ); |
196 return null !== key( $this->blocks ); |
188 } |
197 } |
189 |
198 |
190 /** |
199 /** |
194 * |
203 * |
195 * @link https://www.php.net/manual/en/countable.count.php |
204 * @link https://www.php.net/manual/en/countable.count.php |
196 * |
205 * |
197 * @return int Block count. |
206 * @return int Block count. |
198 */ |
207 */ |
|
208 #[ReturnTypeWillChange] |
199 public function count() { |
209 public function count() { |
200 return count( $this->blocks ); |
210 return count( $this->blocks ); |
201 } |
211 } |
202 |
212 |
203 } |
213 } |