From e302022d4f2cf1d17372e7c87b26ba7c4ea60f79 Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Fri, 18 Oct 2024 11:42:59 +0100 Subject: [PATCH] Issue #3478166 by quietone, smustgrave, mstrelan: Add MissingParamType for form, form_state and form_id (cherry picked from commit dd3beacc990f6160e84c767ed4141e9843d255e0) --- .../Drupal/Core/Form/FormBuilderInterface.php | 2 +- .../Core/Form/FormSubmitterInterface.php | 4 +- core/lib/Drupal/Core/Form/form.api.php | 18 ++-- .../Core/Render/Element/FormElementBase.php | 2 +- core/lib/Drupal/Core/Render/theme.api.php | 4 +- core/modules/field/field.api.php | 4 +- .../media_library/src/Form/FileUploadForm.php | 2 +- core/modules/node/src/NodeForm.php | 4 +- .../Plugin/Field/FieldType/ListItemBase.php | 2 +- .../theme_test/src/ThemeTestPreprocess.php | 2 +- .../views/src/Plugin/views/HandlerBase.php | 79 ++++++++++++++++ .../Plugin/views/ViewsHandlerInterface.php | 5 + .../src/Plugin/views/ViewsPluginInterface.php | 12 +++ .../Plugin/views/filter/FilterPluginBase.php | 92 +++++++++++++++++++ 14 files changed, 210 insertions(+), 22 deletions(-) diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php index a98650c23eb7..a1297a4125a8 100644 --- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php +++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php @@ -154,7 +154,7 @@ public function rebuildForm($form_id, FormStateInterface &$form_state, $old_form * The value must be one of the following: * - The name of a class that implements \Drupal\Core\Form\FormInterface. * - An instance of a class that implements \Drupal\Core\Form\FormInterface. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. Most important is the * $form_state->getValues() collection, a tree of data used to simulate the * incoming \Drupal::request()->request information from a user's form diff --git a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php index c3e0089b0791..9d078b3ca332 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php +++ b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php @@ -27,9 +27,9 @@ public function doSubmitForm(&$form, FormStateInterface &$form_state); * Button-specific handlers are checked first. If none exist, the function * falls back to form-level handlers. * - * @param $form + * @param array $form * An associative array containing the structure of the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. If the user submitted the form by clicking * a button with custom handler functions defined, those handlers will be * stored here. diff --git a/core/lib/Drupal/Core/Form/form.api.php b/core/lib/Drupal/Core/Form/form.api.php index 0502ea323921..210e9f36ed54 100644 --- a/core/lib/Drupal/Core/Form/form.api.php +++ b/core/lib/Drupal/Core/Form/form.api.php @@ -186,13 +186,13 @@ function hook_ajax_render_alter(array &$data) { * hook_form_FORM_ID_alter(). So, for each module, the more general hooks are * called first followed by the more specific. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. The arguments that * \Drupal::formBuilder()->getForm() was originally called with are available * in the array $form_state->getBuildInfo()['args']. - * @param $form_id + * @param string $form_id * A string that is the unique ID of the form, set by * Drupal\Core\Form\FormInterface::getFormId(). * @@ -235,13 +235,13 @@ function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_stat * hook_form_FORM_ID_alter(). So, for each module, the more general hooks are * called first followed by the more specific. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. The arguments that * \Drupal::formBuilder()->getForm() was originally called with are available * in the array $form_state->getBuildInfo()['args']. - * @param $form_id + * @param string $form_id * String representing the name of the form itself. Typically this is the * name of the function that generated the form. * @@ -293,11 +293,11 @@ function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $f * hook_form_FORM_ID_alter(). So, for each module, the more general hooks are * called first followed by the more specific. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. - * @param $form_id + * @param string $form_id * String representing the name of the form itself. Typically this is the * name of the function that generated the form. * diff --git a/core/lib/Drupal/Core/Render/Element/FormElementBase.php b/core/lib/Drupal/Core/Render/Element/FormElementBase.php index 75da91227dc4..bce01e19558d 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElementBase.php +++ b/core/lib/Drupal/Core/Render/Element/FormElementBase.php @@ -132,7 +132,7 @@ public static function processPattern(&$element, FormStateInterface $form_state, * @param $element * An associative array containing the properties and children of the * generic form element. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param array $complete_form * The complete form structure. diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index a67c53299b4e..fa447c200630 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -525,9 +525,9 @@ * Note that the base theme's form alterations will be run before any sub-theme * alterations. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index f8d72a26dbac..b33aa3c282b6 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -257,10 +257,10 @@ function hook_field_widget_single_element_WIDGET_TYPE_form_alter(array &$element /** * Alter the complete form for field widgets provided by other modules. * - * @param $field_widget_complete_form + * @param array $field_widget_complete_form * The field widget form element as constructed by * \Drupal\Core\Field\WidgetBaseInterface::form(). - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param $context * An associative array containing the following key-value pairs: diff --git a/core/modules/media_library/src/Form/FileUploadForm.php b/core/modules/media_library/src/Form/FileUploadForm.php index fd2bc14a419c..e9e25f108fca 100644 --- a/core/modules/media_library/src/Form/FileUploadForm.php +++ b/core/modules/media_library/src/Form/FileUploadForm.php @@ -276,7 +276,7 @@ protected function buildEntityFormElement(MediaInterface $media, array $form, Fo * The entity form source field element. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current form state. - * @param $form + * @param array $form * The complete form. * * @return array diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index bd71a44a3d94..31c97b3cb4c8 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -244,9 +244,9 @@ protected function actions(array $form, FormStateInterface $form_state) { /** * Form submission handler for the 'preview' action. * - * @param $form + * @param array $form * An associative array containing the structure of the form. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ public function preview(array $form, FormStateInterface $form_state) { diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php index 4d9bef51685f..52bb8c76a048 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php @@ -339,7 +339,7 @@ abstract protected function allowedValuesDescription(); * @param $element * An associative array containing the properties and children of the * generic form element. - * @param $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form for the form this element belongs to. * * @see \Drupal\Core\Render\Element\FormElementBase::processPattern() diff --git a/core/modules/system/tests/modules/theme_test/src/ThemeTestPreprocess.php b/core/modules/system/tests/modules/theme_test/src/ThemeTestPreprocess.php index a82849a41aad..ab1c198abb26 100644 --- a/core/modules/system/tests/modules/theme_test/src/ThemeTestPreprocess.php +++ b/core/modules/system/tests/modules/theme_test/src/ThemeTestPreprocess.php @@ -10,7 +10,7 @@ class ThemeTestPreprocess { /** * Preprocess callback for testing preprocess callbacks. * - * @param $variables + * @param array $variables * An associative array containing: * - foo: Text for testing preprocess callback. */ diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index 3c576d13d520..2e4ad4871dc6 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -333,6 +333,12 @@ public function usesGroupBy() { /** * Provide a form for aggregation settings. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildGroupByForm(&$form, FormStateInterface $form_state) { $display_id = $form_state->get('display_id'); @@ -360,6 +366,12 @@ public function buildGroupByForm(&$form, FormStateInterface $form_state) { * Perform any necessary changes to the form values prior to storage. * * There is no need for this function to actually store the data. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitGroupByForm(&$form, FormStateInterface $form_state) { $form_state->get('handler')->options['group_type'] = $form_state->getValue(['options', 'group_type']); @@ -382,11 +394,22 @@ public function defineExtraOptions(&$option) {} /** * Provide a form for setting options. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {} /** * Validate the options form. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function validateExtraOptionsForm($form, FormStateInterface $form_state) {} @@ -394,6 +417,11 @@ public function validateExtraOptionsForm($form, FormStateInterface $form_state) * Perform any necessary changes to the form values prior to storage. * * There is no need for this function to actually store the data. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitExtraOptionsForm($form, FormStateInterface $form_state) {} @@ -416,26 +444,55 @@ public function exposedInfo() {} /** * Render our chunk of the exposed handler form when selecting. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildExposedForm(&$form, FormStateInterface $form_state) {} /** * Validate the exposed handler form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function validateExposed(&$form, FormStateInterface $form_state) {} /** * Submit the exposed handler form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitExposed(&$form, FormStateInterface $form_state) {} /** * Form for exposed handler options. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildExposeForm(&$form, FormStateInterface $form_state) {} /** * Validate the options form. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function validateExposeForm($form, FormStateInterface $form_state) {} @@ -443,16 +500,33 @@ public function validateExposeForm($form, FormStateInterface $form_state) {} * Perform any necessary changes to the form exposes prior to storage. * * There is no need for this function to actually store the data. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitExposeForm($form, FormStateInterface $form_state) {} /** * Shortcut to display the expose/hide button. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function showExposeButton(&$form, FormStateInterface $form_state) {} /** * Shortcut to display the exposed options form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function showExposeForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { @@ -769,6 +843,11 @@ public static function breakString($str, $force_int = FALSE) { /** * Displays the Expose form. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function displayExposedForm($form, FormStateInterface $form_state) { $item = &$this->options; diff --git a/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php b/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php index 8a61d56548c3..cf060c0aa6c5 100644 --- a/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php +++ b/core/modules/views/src/Plugin/views/ViewsHandlerInterface.php @@ -109,6 +109,11 @@ public function postExecute(&$values); /** * Shortcut to display the exposed options form. + * + * @param array $form + * The form array to alter, passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function showExposeForm(&$form, FormStateInterface $form_state); diff --git a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php index 4304be07d8db..7caf2faab0bf 100644 --- a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php +++ b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php @@ -43,6 +43,12 @@ public function filterByDefinedOptions(array &$storage); /** * Validate the options form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function validateOptionsForm(&$form, FormStateInterface $form_state); @@ -82,6 +88,12 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ /** * Handle any special handling on the validate form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitOptionsForm(&$form, FormStateInterface $form_state); diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index 1a844105ca82..495a7c8b3a72 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -235,6 +235,12 @@ public function isAGroup() { * If overridden, it is best to call through to the parent, * or to at least make sure all of the functions in this form * are called. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); @@ -276,6 +282,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { /** * Simple validate handler. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $this->operatorValidate($form, $form_state); @@ -290,6 +302,12 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { /** * Simple submit handler. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function submitOptionsForm(&$form, FormStateInterface $form_state) { // Do not store these values. @@ -323,6 +341,12 @@ public function showOperatorForm(&$form, FormStateInterface $form_state) { * This may be overridden by child classes, and it must * define $form['operator']; * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * * @see buildOptionsForm() */ protected function operatorForm(&$form, FormStateInterface $form_state) { @@ -348,6 +372,11 @@ public function operatorOptions() { /** * Validate the operator form. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function operatorValidate($form, FormStateInterface $form_state) {} @@ -355,11 +384,22 @@ protected function operatorValidate($form, FormStateInterface $form_state) {} * Perform any necessary changes to the form values prior to storage. * * There is no need for this function to actually store the data. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function operatorSubmit($form, FormStateInterface $form_state) {} /** * Shortcut to display the value form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function showValueForm(&$form, FormStateInterface $form_state) { $this->valueForm($form, $form_state); @@ -375,6 +415,12 @@ protected function showValueForm(&$form, FormStateInterface $form_state) { * This should be overridden by all child classes and it must * define $form['value'] * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * * @see buildOptionsForm() */ protected function valueForm(&$form, FormStateInterface $form_state) { @@ -383,6 +429,11 @@ protected function valueForm(&$form, FormStateInterface $form_state) { /** * Validate the options form. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function valueValidate($form, FormStateInterface $form_state) {} @@ -390,11 +441,22 @@ protected function valueValidate($form, FormStateInterface $form_state) {} * Perform any necessary changes to the form values prior to storage. * * There is no need for this function to actually store the data. + * + * @param array $form + * Associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function valueSubmit($form, FormStateInterface $form_state) {} /** * Shortcut to display the exposed options form. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function showBuildGroupForm(&$form, FormStateInterface $form_state) { if (empty($this->options['is_grouped'])) { @@ -418,6 +480,12 @@ public function showBuildGroupForm(&$form, FormStateInterface $form_state) { /** * Shortcut to display the build_group/hide button. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function showBuildGroupButton(&$form, FormStateInterface $form_state) { @@ -495,6 +563,12 @@ public function buildGroupForm($form, FormStateInterface $form_state) { /** * Shortcut to display the expose/hide button. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function showExposeButton(&$form, FormStateInterface $form_state) { $form['expose_button'] = [ @@ -545,6 +619,12 @@ public function showExposeButton(&$form, FormStateInterface $form_state) { /** * Options form subform for exposed filter options. * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * * @see buildOptionsForm() */ public function buildExposeForm(&$form, FormStateInterface $form_state) { @@ -938,6 +1018,12 @@ public function groupForm(&$form, FormStateInterface $form_state) { * Render our chunk of the exposed filter form when selecting. * * You can override this if it doesn't do what you expect. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ public function buildExposedForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { @@ -1034,6 +1120,12 @@ protected function buildValueWrapper(&$form, $wrapper_identifier) { * Build the form to let users create the group of exposed filters. * * This form is displayed when users click on button 'Build group'. + * + * @param array $form + * An alterable, associative array containing the structure of the form, + * passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ protected function buildExposedFiltersGroupForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) { -- GitLab