|
26 | 26 | */ |
27 | 27 | class Block_Command extends WP_CLI_Command { |
28 | 28 |
|
29 | | - private $fields = array( |
| 29 | + private $fields = [ |
30 | 30 | 'name', |
31 | 31 | 'title', |
32 | 32 | 'description', |
33 | 33 | 'category', |
34 | | - ); |
| 34 | + ]; |
35 | 35 |
|
36 | 36 | /** |
37 | 37 | * Lists registered block types. |
@@ -102,7 +102,7 @@ public function list_( $args, $assoc_args ) { |
102 | 102 | $registry = WP_Block_Type_Registry::get_instance(); |
103 | 103 | $blocks = $registry->get_all_registered(); |
104 | 104 |
|
105 | | - $items = array(); |
| 105 | + $items = []; |
106 | 106 | foreach ( $blocks as $block ) { |
107 | 107 | $items[] = $this->prepare_block_for_output( $block ); |
108 | 108 | } |
@@ -187,24 +187,24 @@ public function get( $args, $assoc_args ) { |
187 | 187 | * @return array Prepared block data. |
188 | 188 | */ |
189 | 189 | private function prepare_block_for_output( $block ) { |
190 | | - return array( |
| 190 | + return [ |
191 | 191 | 'name' => $block->name, |
192 | | - 'title' => $block->title ?? '', |
193 | | - 'description' => $block->description ?? '', |
| 192 | + 'title' => $block->title ?? '', // @phpstan-ignore-line (added in WP 5.5) |
| 193 | + 'description' => $block->description ?? '', // @phpstan-ignore-line (added in WP 5.5) |
194 | 194 | 'category' => $block->category ?? '', |
195 | 195 | 'parent' => $block->parent ?? null, |
196 | 196 | 'icon' => $block->icon ?? '', |
197 | | - 'keywords' => $block->keywords ?? array(), |
| 197 | + 'keywords' => $block->keywords ?? [], // @phpstan-ignore-line (added in WP 5.5) |
198 | 198 | 'textdomain' => $block->textdomain ?? '', |
199 | | - 'supports' => $block->supports ?? array(), |
200 | | - 'styles' => $block->styles ?? array(), |
201 | | - 'variations' => $block->variations ?? array(), |
202 | | - 'api_version' => $block->api_version ?? 1, |
| 199 | + 'supports' => $block->supports ?? [], |
| 200 | + 'styles' => $block->styles ?? [], // @phpstan-ignore-line (added in WP 5.5) |
| 201 | + 'variations' => $block->variations ?? [], // added in WP 5.8 and replaced with magic getter in 6.1 |
| 202 | + 'api_version' => $block->api_version ?? 1, // @phpstan-ignore-line (added in WP 5.6) |
203 | 203 | 'editor_script' => $block->editor_script ?? '', |
204 | 204 | 'editor_style' => $block->editor_style ?? '', |
205 | 205 | 'script' => $block->script ?? '', |
206 | 206 | 'style' => $block->style ?? '', |
207 | | - ); |
| 207 | + ]; |
208 | 208 | } |
209 | 209 |
|
210 | 210 | /** |
|
0 commit comments