Skip to content

Commit a2621d6

Browse files
Block Supports: Narrow the docblock types of the block supports helper.
1 parent 896ba07 commit a2621d6

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎src/wp-includes/block-supports/utils.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ function wp_should_skip_block_supports_serialization( $block_type, $feature_set,
4141
*
4242
* @since 7.3.0
4343
*
44-
* @param array $block_attributes Block attributes.
45-
* @param array|null $supports Optional. Supports to include: any of `background`, `color`,
46-
* `border`, `shadow` and `spacing`. Default null, for all of them.
47-
* @return array Array with `class` and `style` keys, each present only when non-empty.
44+
* @param array<string, mixed> $block_attributes Block attributes.
45+
* @param string[]|null $supports Optional. Supports to include: any of `background`, `color`,
46+
* `border`, `shadow` and `spacing`. Unknown names are ignored.
47+
* Default null, for all of them.
48+
* @return array<string, string> Array with `class` and `style` keys, each present only when non-empty.
49+
*
50+
* @phpstan-return array{ class?: non-empty-string, style?: non-empty-string }
4851
*/
4952
function wp_get_block_supports_classes_and_styles( $block_attributes, $supports = null ) {
5053
// Follows the style engine's group order.

‎tests/phpunit/tests/block-supports/wpGetBlockSupportsClassesAndStyles.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ class Tests_Block_Supports_WpGetBlockSupportsClassesAndStyles extends WP_UnitTes
1212
*
1313
* @dataProvider data_get_block_supports_classes_and_styles
1414
*
15-
* @param mixed $block_attributes Block attributes.
16-
* @param array|null $supports Supports to include.
17-
* @param array $expected Expected classes and styles.
15+
* @param array<string, mixed>|null $block_attributes Block attributes, or null to check the guard.
16+
* @param string[]|null $supports Supports to include.
17+
* @param array<string, string> $expected Expected classes and styles.
1818
*/
1919
public function test_get_block_supports_classes_and_styles( $block_attributes, $supports, $expected ) {
2020
$this->assertSame( $expected, wp_get_block_supports_classes_and_styles( $block_attributes, $supports ) );
2121
}
2222

2323
/**
24-
* Data provider.
24+
* Data provider for {@see self::test_get_block_supports_classes_and_styles()}.
2525
*
26-
* @return array[]
26+
* @return array<string, array{ block_attributes: array<string, mixed>|null, supports: string[]|null, expected: array{ class?: non-empty-string, style?: non-empty-string } }>
2727
*/
2828
public static function data_get_block_supports_classes_and_styles() {
2929
$block_attributes = array(

0 commit comments

Comments
 (0)