diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index 82da1f3ff0c3..7eb120306dd2 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -545,11 +545,6 @@ parameters: count: 1 path: system/Helpers/filesystem_helper.php - - - message: "#^Offset 'checked' on array\\{type\\: 'checkbox', name\\: mixed, value\\: string\\} in isset\\(\\) does not exist\\.$#" - count: 1 - path: system/Helpers/form_helper.php - - message: "#^Binary operation \"\\+\" between 0 and string results in an error\\.$#" count: 1 diff --git a/system/Common.php b/system/Common.php index 634d8c61e71e..2c78a92c5bc8 100644 --- a/system/Common.php +++ b/system/Common.php @@ -1054,7 +1054,7 @@ function slash_item(string $item): ?string * Helper function used to convert a string, array, or object * of attributes to a string. * - * @param mixed $attributes string, array, object + * @param array|object|string $attributes string, array, object that can be cast to array */ function stringify_attributes($attributes, bool $js = false): string { diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index aac4736b2514..f209991746be 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -137,8 +137,8 @@ function form_hidden($name, $value = '', bool $recursing = false): string * Text Input Field. If 'type' is passed in the $type field, it will be * used as the input type, for making 'email', 'phone', etc input fields. * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_input($data = '', string $value = '', $extra = '', string $type = 'text'): string { @@ -158,8 +158,8 @@ function form_input($data = '', string $value = '', $extra = '', string $type = * * Identical to the input function but adds the "password" type * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_password($data = '', string $value = '', $extra = ''): string { @@ -178,8 +178,8 @@ function form_password($data = '', string $value = '', $extra = ''): string * * Identical to the input function but adds the "file" type * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_upload($data = '', string $value = '', $extra = ''): string { @@ -202,8 +202,8 @@ function form_upload($data = '', string $value = '', $extra = ''): string /** * Textarea field * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_textarea($data = '', string $value = '', $extra = ''): string { @@ -238,8 +238,8 @@ function form_textarea($data = '', string $value = '', $extra = ''): string /** * Multi-select menu * - * @param mixed $name - * @param mixed $extra + * @param array|string $name + * @param array|object|string $extra string, array, object that can be cast to array */ function form_multiselect($name = '', array $options = [], array $selected = [], $extra = ''): string { @@ -257,10 +257,10 @@ function form_multiselect($name = '', array $options = [], array $selected = [], /** * Drop-down Menu * - * @param mixed $data - * @param mixed $options - * @param mixed $selected - * @param mixed $extra + * @param array|string $data + * @param array|string $options + * @param array|string $selected + * @param array|object|string $extra string, array, object that can be cast to array */ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): string { @@ -340,8 +340,8 @@ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): /** * Checkbox Field * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_checkbox($data = '', string $value = '', bool $checked = false, $extra = ''): string { @@ -353,6 +353,7 @@ function form_checkbox($data = '', string $value = '', bool $checked = false, $e if (is_array($data) && array_key_exists('checked', $data)) { $checked = $data['checked']; + if ($checked === false) { unset($data['checked']); } else { @@ -362,8 +363,6 @@ function form_checkbox($data = '', string $value = '', bool $checked = false, $e if ($checked === true) { $defaults['checked'] = 'checked'; - } elseif (isset($defaults['checked'])) { - unset($defaults['checked']); } return '\n"; @@ -374,8 +373,8 @@ function form_checkbox($data = '', string $value = '', bool $checked = false, $e /** * Radio Button * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_radio($data = '', string $value = '', bool $checked = false, $extra = ''): string { @@ -392,8 +391,8 @@ function form_radio($data = '', string $value = '', bool $checked = false, $extr /** * Submit Button * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_submit($data = '', string $value = '', $extra = ''): string { @@ -405,8 +404,8 @@ function form_submit($data = '', string $value = '', $extra = ''): string /** * Reset Button * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_reset($data = '', string $value = '', $extra = ''): string { @@ -418,8 +417,8 @@ function form_reset($data = '', string $value = '', $extra = ''): string /** * Form Button * - * @param mixed $data - * @param mixed $extra + * @param array|string $data + * @param array|object|string $extra string, array, object that can be cast to array */ function form_button($data = '', string $content = '', $extra = ''): string {