| @@ -30,10 +30,10 @@ | ||
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Process the [content_control] shortcode. |
| 33 | 33 | * |
| 34 | - * @param array $atts Array or shortcode attributes. | |
| 35 | - * @param string $content Content inside shortcode. | |
| 34 | + * @param array<string,string|int|null> $atts Array or shortcode attributes. | |
| 35 | + * @param string $content Content inside shortcode. | |
| 36 | 36 | * |
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | 39 | public function content_control( $atts, $content = '' ) { |
| @@ -71,14 +71,11 @@ | ||
| 71 | 71 | $user_roles = $atts['allowed_roles']; |
| 72 | 72 | $match_type = 'match'; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $classes = $atts['class']; | |
| 75 | + // Convert classes to array. | |
| 76 | + $classes = ! empty( $atts['class'] ) ? explode( ' ', $atts['class'] ) : []; | |
| 76 | 77 | |
| 77 | - if ( ! is_array( $classes ) ) { | |
| 78 | - $classes = ! empty( $classes ) ? explode( ' ', $classes ) : []; | |
| 79 | - } | |
| 80 | - | |
| 81 | 78 | $classes[] = 'content-control-container'; |
| 82 | 79 | // @deprecated 2.0.0 |
| 83 | 80 | $classes[] = 'jp-cc'; |
| 84 | 81 | |
| @@ -103,17 +100,17 @@ | ||
| 103 | 100 | * Takes set but empty attributes and sets them to true. |
| 104 | 101 | * |
| 105 | 102 | * These are typically valueless boolean attributes. |
| 106 | 103 | * |
| 107 | - * @param array $atts Array of shortcode attributes. | |
| 104 | + * @param array<string|int,string|int|null> $atts Array of shortcode attributes. | |
| 108 | 105 | * |
| 109 | - * @return mixed | |
| 106 | + * @return (int|null|string|true)[] | |
| 107 | + * | |
| 108 | + * @psalm-return array<int|string, int|null|string|true> | |
| 110 | 109 | */ |
| 111 | 110 | public function normalize_empty_atts( $atts = [] ) { |
| 112 | - if ( ! is_array( $atts ) ) { | |
| 113 | - if ( empty( $atts ) ) { | |
| 114 | - $atts = []; | |
| 115 | - } | |
| 111 | + if ( ! is_array( $atts ) || empty( $atts ) ) { | |
| 112 | + $atts = []; | |
| 116 | 113 | } |
| 117 | 114 | |
| 118 | 115 | foreach ( $atts as $attribute => $value ) { |
| 119 | 116 | if ( is_int( $attribute ) ) { |