Changeset 63524
- Timestamp:
- 09/08/2026 06:04:10 AM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/wp-includes/class-wp-block-styles-registry.php (modified) (5 diffs)
-
src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php (modified) (1 diff)
-
tests/phpstan/base.neon (modified) (1 diff)
-
tests/phpstan/baselines/argument.type.neon (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-styles-registry.php
r63443 r63524 20 20 * @since 5.3.0 21 21 * 22 * @var array[] 22 * @var array<string, array<string, array<string, mixed>>> 23 * @phpstan-var array<string, array<string, Block_Style_Properties>> 23 24 */ 24 25 private $registered_block_styles = array(); … … 51 52 * Array containing the properties of the style. 52 53 * 53 * @type string $name The identifier of the style used to compute a CSS class.54 * @type string $label A human-readable label for the style.55 * @type string $inline_style Inline CSS code that registers the CSS class required56 * for the style.57 * @type string $style_handle The handle to an already registered style that should be58 * enqueued in places where block styles are needed.59 * @type bool $is_default Whether this is the default style for the block type.60 * @type array $style_data Theme.json-like object to generate CSS from.54 * @type string $name The identifier of the style used to compute a CSS class. 55 * @type string $label A human-readable label for the style. 56 * @type string $inline_style Inline CSS code that registers the CSS class required 57 * for the style. 58 * @type string $style_handle The handle to an already registered style that should be 59 * enqueued in places where block styles are needed. 60 * @type bool $is_default Whether this is the default style for the block type. 61 * @type array<string, mixed> $style_data Theme.json-like object to generate CSS from. 61 62 * } 62 63 * @return bool True if the block style was registered with success and false otherwise. … … 141 142 * @param string $block_name Block type name including namespace. 142 143 * @param string $block_style_name Block style name. 143 * @return array|null Registered block style properties or `null` if the block style is not registered. 144 * @return array<string, mixed>|null Registered block style properties or `null` if the block style is not registered. 145 * @phpstan-return Block_Style_Properties|null 144 146 */ 145 147 public function get_registered( $block_name, $block_style_name ) { … … 156 158 * @since 5.3.0 157 159 * 158 * @return array[] Array of arrays containing the registered block styles properties grouped by block type. 160 * @return array<string, array<string, array<string, mixed>>> Array of arrays containing the registered block styles 161 * properties grouped by block type. 162 * @phpstan-return array<string, array<string, Block_Style_Properties>> 159 163 */ 160 164 public function get_all_registered() { … … 168 172 * 169 173 * @param string $block_name Block type name including namespace. 170 * @return array[] Array whose keys are block style names and whose values are block style properties. 174 * @return array<string, array<string, mixed>> Array whose keys are block style names and whose values are 175 * block style properties. 176 * @phpstan-return array<string, Block_Style_Properties> 171 177 */ 172 178 public function get_registered_styles_for_block( $block_name ) { -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
r59970 r63524 331 331 332 332 if ( rest_is_field_included( 'styles', $fields ) ) { 333 $styles = $this->style_registry->get_registered_styles_for_block( $block_type->name ); 334 $styles = array_values( $styles ); 335 $data['styles'] = wp_parse_args( $styles, $data['styles'] ); 333 $styles = $this->style_registry->get_registered_styles_for_block( $block_type->name ); 334 $styles = array_values( $styles ); 335 336 /* 337 * The loop above assigns this key from rest_sanitize_value_from_schema(), whose 338 * return is documented as `mixed|WP_Error`, so what the styles came back as has 339 * to be restated here. A WP_Error is why the value is checked rather than cast. 340 */ 341 /** 342 * @var array<string, mixed>[] $block_styles 343 * @phpstan-var list<Block_Style_Properties> $block_styles 344 */ 345 $block_styles = isset( $data['styles'] ) && is_array( $data['styles'] ) ? $data['styles'] : array(); 346 347 $data['styles'] = array_merge( $block_styles, $styles ); 336 348 $data['styles'] = array_filter( $data['styles'] ); 337 349 } -
trunk/tests/phpstan/base.neon
r63462 r63524 277 277 } 278 278 ''' 279 280 # The properties of a block style as WP_Block_Styles_Registry stores them, which is 281 # more than its register() hash accepts: `name` is required for a style to be 282 # registered at all, and `label` is filled in from the name when the caller omits 283 # it, so both are always present on the way back out. The shape stays open because 284 # the array is stored verbatim, so a caller's own keys survive — including into the 285 # REST response, which does not set `additionalProperties` to false. Read from 286 # procedural files as well as classes, which is why it is declared here. 287 Block_Style_Properties: ''' 288 array{ 289 name: string, 290 label: string, 291 inline_style?: string, 292 style_handle?: string, 293 is_default?: bool, 294 style_data?: array<string, mixed>, 295 ... 296 } 297 ''' -
trunk/tests/phpstan/baselines/argument.type.neon
r63522 r63524 1250 1250 path: ../../../src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php 1251 1251 - 1252 message: '#^Parameter \#1 \$args of function wp_parse_args expects array\<string, mixed\>\|object\|string, list\<array\> given\.$#'1253 identifier: argument.type1254 count: 11255 path: ../../../src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php1256 -1257 1252 message: '#^Parameter \#2 \$value of method WP_HTTP_Response\:\:header\(\) expects string, int given\.$#' 1258 1253 identifier: argument.type
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)