From c55ad54975ebf4cf8e3dc7887faca4736a0e3f45 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Thu, 19 Dec 2024 11:06:55 +1000 Subject: [PATCH] Issue #3491289 by quietone: Fix Drupal.Commenting.FunctionComment.Missing in views filter plugins --- .../views/filter/StatisticsLastUpdated.php | 3 ++ .../src/Plugin/views/filter/UserUid.php | 3 ++ .../file/src/Plugin/views/filter/Status.php | 3 ++ .../node/src/Plugin/views/filter/Access.php | 9 +++++ .../node/src/Plugin/views/filter/Status.php | 12 ++++++ .../src/Plugin/views/filter/UidRevision.php | 3 ++ .../Plugin/views/filter/TaxonomyIndexTid.php | 30 ++++++++++++++ .../views/filter/TaxonomyIndexTidDepth.php | 12 ++++++ .../user/src/Plugin/views/filter/Current.php | 3 ++ .../user/src/Plugin/views/filter/Name.php | 18 +++++++++ .../src/Plugin/views/filter/Permissions.php | 3 ++ .../Plugin/views/filter/BooleanOperator.php | 15 +++++++ .../views/filter/BooleanOperatorString.php | 3 ++ .../views/src/Plugin/views/filter/Combine.php | 33 ++++++++++++++++ .../views/src/Plugin/views/filter/Date.php | 18 +++++++++ .../Plugin/views/filter/FilterPluginBase.php | 6 +++ .../Plugin/views/filter/GroupByNumeric.php | 18 +++++++++ .../src/Plugin/views/filter/InOperator.php | 33 ++++++++++++++++ .../src/Plugin/views/filter/ManyToOne.php | 9 +++++ .../src/Plugin/views/filter/NumericFilter.php | 18 +++++++++ .../src/Plugin/views/filter/StringFilter.php | 39 +++++++++++++++++++ .../src/Plugin/views/access/StaticTest.php | 3 ++ core/phpcs.xml.dist | 5 +++ 23 files changed, 299 insertions(+) diff --git a/core/modules/comment/src/Plugin/views/filter/StatisticsLastUpdated.php b/core/modules/comment/src/Plugin/views/filter/StatisticsLastUpdated.php index 950bffc78ebc..837725154f24 100644 --- a/core/modules/comment/src/Plugin/views/filter/StatisticsLastUpdated.php +++ b/core/modules/comment/src/Plugin/views/filter/StatisticsLastUpdated.php @@ -19,6 +19,9 @@ class StatisticsLastUpdated extends Date { // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing protected ?string $node_table; + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); $this->node_table = $this->query->ensureTable('node', $this->relationship); diff --git a/core/modules/comment/src/Plugin/views/filter/UserUid.php b/core/modules/comment/src/Plugin/views/filter/UserUid.php index 6e53aa3e5f8e..89b85cd2ae79 100644 --- a/core/modules/comment/src/Plugin/views/filter/UserUid.php +++ b/core/modules/comment/src/Plugin/views/filter/UserUid.php @@ -14,6 +14,9 @@ #[ViewsFilter("comment_user_uid")] class UserUid extends FilterPluginBase { + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); diff --git a/core/modules/file/src/Plugin/views/filter/Status.php b/core/modules/file/src/Plugin/views/filter/Status.php index 8cf4c6239b50..d386b862288f 100644 --- a/core/modules/file/src/Plugin/views/filter/Status.php +++ b/core/modules/file/src/Plugin/views/filter/Status.php @@ -14,6 +14,9 @@ #[ViewsFilter("file_status")] class Status extends InOperator { + /** + * {@inheritdoc} + */ public function getValueOptions() { if (!isset($this->valueOptions)) { $this->valueOptions = [ diff --git a/core/modules/node/src/Plugin/views/filter/Access.php b/core/modules/node/src/Plugin/views/filter/Access.php index 37db538b7bd9..4934a2f2e635 100644 --- a/core/modules/node/src/Plugin/views/filter/Access.php +++ b/core/modules/node/src/Plugin/views/filter/Access.php @@ -14,10 +14,19 @@ #[ViewsFilter("node_access")] class Access extends FilterPluginBase { + /** + * {@inheritdoc} + */ public function adminSummary() {} + /** + * {@inheritdoc} + */ protected function operatorForm(&$form, FormStateInterface $form_state) {} + /** + * {@inheritdoc} + */ public function canExpose() { return FALSE; } diff --git a/core/modules/node/src/Plugin/views/filter/Status.php b/core/modules/node/src/Plugin/views/filter/Status.php index a0cd335bee0e..fbe7d3578a50 100644 --- a/core/modules/node/src/Plugin/views/filter/Status.php +++ b/core/modules/node/src/Plugin/views/filter/Status.php @@ -14,14 +14,26 @@ #[ViewsFilter("node_status")] class Status extends FilterPluginBase { + /** + * {@inheritdoc} + */ public function adminSummary() {} + /** + * {@inheritdoc} + */ protected function operatorForm(&$form, FormStateInterface $form_state) {} + /** + * {@inheritdoc} + */ public function canExpose() { return FALSE; } + /** + * {@inheritdoc} + */ public function query() { $table = $this->ensureMyTable(); $snippet = "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1"; diff --git a/core/modules/node/src/Plugin/views/filter/UidRevision.php b/core/modules/node/src/Plugin/views/filter/UidRevision.php index 7f986549c2fe..b7f186fa07d1 100644 --- a/core/modules/node/src/Plugin/views/filter/UidRevision.php +++ b/core/modules/node/src/Plugin/views/filter/UidRevision.php @@ -13,6 +13,9 @@ #[ViewsFilter("node_uid_revision")] class UidRevision extends Name { + /** + * {@inheritdoc} + */ public function query($group_by = FALSE) { $this->ensureMyTable(); diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 4cad71a81d16..49a05d4c901d 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -99,6 +99,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ } } + /** + * {@inheritdoc} + */ public function hasExtraOptions() { return TRUE; } @@ -110,6 +113,9 @@ public function getValueOptions() { return $this->valueOptions; } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -122,6 +128,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { $vocabularies = $this->vocabularyStorage->loadMultiple(); $options = []; @@ -166,6 +175,9 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { ]; } + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { $vocabulary = $this->vocabularyStorage->load($this->options['vid']); if (empty($vocabulary) && $this->options['limit']) { @@ -285,6 +297,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ protected function valueValidate($form, FormStateInterface $form_state) { // We only validate if they've chosen the text field style. if ($this->options['type'] != 'textfield') { @@ -300,6 +315,9 @@ protected function valueValidate($form, FormStateInterface $form_state) { $form_state->setValue(['options', 'value'], $tids); } + /** + * {@inheritdoc} + */ public function acceptExposedInput($input) { if (empty($this->options['exposed'])) { return TRUE; @@ -339,6 +357,9 @@ public function acceptExposedInput($input) { return $rc; } + /** + * {@inheritdoc} + */ public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; @@ -371,10 +392,16 @@ public function validateExposed(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ protected function valueSubmit($form, FormStateInterface $form_state) { // Prevent array_filter from messing up our arrays in parent submit. } + /** + * {@inheritdoc} + */ public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); if ($this->options['type'] != 'select') { @@ -387,6 +414,9 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { ]; } + /** + * {@inheritdoc} + */ public function adminSummary() { // Set up $this->valueOptions for the parent summary $this->valueOptions = []; diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php index f54df951646e..69067ce820f2 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php @@ -18,12 +18,18 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid { use TaxonomyIndexDepthQueryTrait; + /** + * {@inheritdoc} + */ public function operatorOptions($which = 'title') { return [ 'or' => $this->t('Is one of'), ]; } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -32,6 +38,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { parent::buildExtraOptionsForm($form, $form_state); @@ -43,6 +52,9 @@ public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { ]; } + /** + * {@inheritdoc} + */ public function query() { // If no filter values are present, then do nothing. if (count($this->value) == 0) { diff --git a/core/modules/user/src/Plugin/views/filter/Current.php b/core/modules/user/src/Plugin/views/filter/Current.php index 07871fa24afe..b8fb28e89039 100644 --- a/core/modules/user/src/Plugin/views/filter/Current.php +++ b/core/modules/user/src/Plugin/views/filter/Current.php @@ -24,6 +24,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ $this->value_value = $this->t('Is the logged in user'); } + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php index 6d18d5f1560d..61d7415495f1 100644 --- a/core/modules/user/src/Plugin/views/filter/Name.php +++ b/core/modules/user/src/Plugin/views/filter/Name.php @@ -27,6 +27,9 @@ class Name extends InOperator { // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing protected array $validated_exposed_input; + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { $users = $this->value ? User::loadMultiple($this->value) : []; $default_value = EntityAutocomplete::getEntityLabels($users); @@ -47,6 +50,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ protected function valueValidate($form, FormStateInterface $form_state) { $uids = []; if ($values = $form_state->getValue(['options', 'value'])) { @@ -58,6 +64,9 @@ protected function valueValidate($form, FormStateInterface $form_state) { $form_state->setValue(['options', 'value'], $uids); } + /** + * {@inheritdoc} + */ public function acceptExposedInput($input) { $rc = parent::acceptExposedInput($input); @@ -71,6 +80,9 @@ public function acceptExposedInput($input) { return $rc; } + /** + * {@inheritdoc} + */ public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; @@ -101,6 +113,9 @@ public function validateExposed(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ protected function valueSubmit($form, FormStateInterface $form_state) { // Prevent array filter from removing our anonymous user. } @@ -112,6 +127,9 @@ public function getValueOptions() { return $this->valueOptions; } + /** + * {@inheritdoc} + */ public function adminSummary() { // Set up $this->valueOptions for the parent summary $this->valueOptions = []; diff --git a/core/modules/user/src/Plugin/views/filter/Permissions.php b/core/modules/user/src/Plugin/views/filter/Permissions.php index d0add56d04ae..e4b2e449c27b 100644 --- a/core/modules/user/src/Plugin/views/filter/Permissions.php +++ b/core/modules/user/src/Plugin/views/filter/Permissions.php @@ -77,6 +77,9 @@ public static function create(ContainerInterface $container, array $configuratio ); } + /** + * {@inheritdoc} + */ public function getValueOptions() { if (!isset($this->valueOptions)) { $permissions = $this->permissionHandler->getPermissions(); diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php index fd7ffd683b54..9be5da491671 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php @@ -178,6 +178,9 @@ public function getValueOptions() { return $this->valueOptions; } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -186,6 +189,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = []; @@ -242,12 +248,18 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ protected function valueValidate($form, FormStateInterface $form_state) { if ($form_state->getValue(['options', 'value']) == 'All' && !$form_state->isValueEmpty(['options', 'expose', 'required'])) { $form_state->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.')); } } + /** + * {@inheritdoc} + */ public function adminSummary() { if ($this->isAGroup()) { return $this->t('grouped'); @@ -270,6 +282,9 @@ public function adminSummary() { return $this->operator; } + /** + * {@inheritdoc} + */ public function defaultExposeOptions() { parent::defaultExposeOptions(); $this->options['expose']['operator_id'] = ''; diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperatorString.php b/core/modules/views/src/Plugin/views/filter/BooleanOperatorString.php index b662aafa5f15..fe97b21a02b2 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperatorString.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperatorString.php @@ -18,6 +18,9 @@ #[ViewsFilter("boolean_string")] class BooleanOperatorString extends BooleanOperator { + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); $where = "$this->tableAlias.$this->realField "; diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php index d4c622e0e794..7da1d6bef71d 100644 --- a/core/modules/views/src/Plugin/views/filter/Combine.php +++ b/core/modules/views/src/Plugin/views/filter/Combine.php @@ -18,6 +18,9 @@ class Combine extends StringFilter { */ public $query; + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); $options['fields'] = ['default' => []]; @@ -25,6 +28,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $this->view->initStyle(); @@ -55,6 +61,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ public function query() { $this->view->_build('field'); $fields = []; @@ -138,6 +147,9 @@ public function opEqual($expression) { $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]); } + /** + * {@inheritdoc} + */ protected function opContains($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('LIKE'); @@ -178,42 +190,63 @@ protected function opContainsWord($expression) { } } + /** + * {@inheritdoc} + */ protected function opStartsWith($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('LIKE'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->connection->escapeLike($this->value) . '%']); } + /** + * {@inheritdoc} + */ protected function opNotStartsWith($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->connection->escapeLike($this->value) . '%']); } + /** + * {@inheritdoc} + */ protected function opEndsWith($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('LIKE'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => '%' . $this->connection->escapeLike($this->value)]); } + /** + * {@inheritdoc} + */ protected function opNotEndsWith($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => '%' . $this->connection->escapeLike($this->value)]); } + /** + * {@inheritdoc} + */ protected function opNotLike($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => '%' . $this->connection->escapeLike($this->value) . '%']); } + /** + * {@inheritdoc} + */ protected function opRegex($expression) { $placeholder = $this->placeholder(); $operator = $this->getConditionOperator('REGEXP'); $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]); } + /** + * {@inheritdoc} + */ protected function opEmpty($expression) { if ($this->operator == 'empty') { $operator = "IS NULL"; diff --git a/core/modules/views/src/Plugin/views/filter/Date.php b/core/modules/views/src/Plugin/views/filter/Date.php index 84d776c4b64a..60b90b37c4ee 100644 --- a/core/modules/views/src/Plugin/views/filter/Date.php +++ b/core/modules/views/src/Plugin/views/filter/Date.php @@ -13,6 +13,9 @@ #[ViewsFilter("date")] class Date extends NumericFilter { + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -40,6 +43,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); } + /** + * {@inheritdoc} + */ public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); @@ -51,6 +57,9 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $this->validateValidTime($form['value'], $form_state, $form_state->getValue(['options', 'operator']), $form_state->getValue(['options', 'value'])); } + /** + * {@inheritdoc} + */ public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; @@ -116,6 +125,9 @@ protected function hasValidGroupedValue(array $group) { return $actual == $expected; } + /** + * {@inheritdoc} + */ public function acceptExposedInput($input) { if (empty($this->options['exposed'])) { return TRUE; @@ -165,6 +177,9 @@ public function acceptExposedInput($input) { return $rc; } + /** + * {@inheritdoc} + */ protected function opBetween($field) { $a = intval(strtotime($this->value['min'], 0)); $b = intval(strtotime($this->value['max'], 0)); @@ -181,6 +196,9 @@ protected function opBetween($field) { $this->query->addWhereExpression($this->options['group'], "$field $operator $a AND $b"); } + /** + * {@inheritdoc} + */ protected function opSimple($field) { $value = intval(strtotime($this->value['value'], 0)); if (!empty($this->value['type']) && $this->value['type'] == 'offset') { diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index 21c4a81a7259..35197e155cf2 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -151,6 +151,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ } } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -1645,6 +1648,9 @@ public function acceptExposedInput($input) { return TRUE; } + /** + * {@inheritdoc} + */ public function storeExposedInput($input, $status) { if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) { return TRUE; diff --git a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php index d05c8f7d6b3d..e9f813554538 100644 --- a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php +++ b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php @@ -12,6 +12,9 @@ #[ViewsFilter("groupby_numeric")] class GroupByNumeric extends NumericFilter { + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); $field = $this->getField(); @@ -22,6 +25,9 @@ public function query() { } } + /** + * {@inheritdoc} + */ protected function opBetween($field) { $placeholder_min = $this->placeholder(); $placeholder_max = $this->placeholder(); @@ -34,11 +40,17 @@ protected function opBetween($field) { } } + /** + * {@inheritdoc} + */ protected function opSimple($field) { $placeholder = $this->placeholder(); $this->query->addHavingExpression($this->options['group'], "$field $this->operator $placeholder", [$placeholder => $this->value['value']]); } + /** + * {@inheritdoc} + */ protected function opEmpty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; @@ -50,10 +62,16 @@ protected function opEmpty($field) { $this->query->addHavingExpression($this->options['group'], "$field $operator"); } + /** + * {@inheritdoc} + */ public function adminLabel($short = FALSE) { return $this->getField(parent::adminLabel($short)); } + /** + * {@inheritdoc} + */ public function canGroup() { return FALSE; } diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php index bde4e41c11d7..85c53950ed66 100644 --- a/core/modules/views/src/Plugin/views/filter/InOperator.php +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php @@ -83,11 +83,17 @@ public function getValueOptions() { return $this->valueOptions; } + /** + * {@inheritdoc} + */ public function defaultExposeOptions() { parent::defaultExposeOptions(); $this->options['expose']['reduce'] = FALSE; } + /** + * {@inheritdoc} + */ public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); $form['expose']['reduce'] = [ @@ -99,6 +105,9 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { ]; } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -162,6 +171,9 @@ public function operatorOptions($which = 'title') { return $options; } + /** + * Gets the operators that have a given number of values. + */ protected function operatorValues($values = 1) { $options = []; foreach ($this->operators() as $id => $info) { @@ -173,6 +185,9 @@ protected function operatorValues($values = 1) { return $options; } + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = []; $options = []; @@ -310,6 +325,9 @@ public function acceptExposedInput($input) { return parent::acceptExposedInput($input); } + /** + * {@inheritdoc} + */ protected function valueSubmit($form, FormStateInterface $form_state) { // Drupal's FAPI system automatically puts '0' in for any checkbox that // was not set, and the key to the checkbox if it is set. @@ -323,6 +341,9 @@ protected function valueSubmit($form, FormStateInterface $form_state) { $form_state->setValue(['options', 'value'], $form['value']['#value']); } + /** + * {@inheritdoc} + */ public function adminSummary() { if ($this->isAGroup()) { return $this->t('grouped'); @@ -387,6 +408,9 @@ public function adminSummary() { return $operator . (($values !== '') ? ' ' . $values : ''); } + /** + * {@inheritdoc} + */ public function query() { $info = $this->operators(); if (!empty($info[$this->operator]['method'])) { @@ -394,6 +418,9 @@ public function query() { } } + /** + * Filters by a simple operator. + */ protected function opSimple() { if (empty($this->value)) { return; @@ -405,6 +432,9 @@ protected function opSimple() { $this->query->addWhere($this->options['group'], "$this->tableAlias.$this->realField", array_values($this->value), $this->operator); } + /** + * Filters by operator 'empty'. + */ protected function opEmpty() { $this->ensureMyTable(); if ($this->operator == 'empty') { @@ -417,6 +447,9 @@ protected function opEmpty() { $this->query->addWhere($this->options['group'], "$this->tableAlias.$this->realField", NULL, $operator); } + /** + * {@inheritdoc} + */ public function validate() { $this->getValueOptions(); $errors = parent::validate(); diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php index c086dcb24c5a..9fe4c6c6107e 100644 --- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php @@ -38,6 +38,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ $this->helper = new ManyToOneHelper($this); } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -111,6 +114,9 @@ public function operators() { */ protected $valueFormType = 'select'; + /** + * {@inheritdoc} + */ protected function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); @@ -132,6 +138,9 @@ public function ensureMyTable() { return parent::ensureMyTable(); } + /** + * Adds a filter. + */ protected function opHelper() { if (empty($this->value)) { return; diff --git a/core/modules/views/src/Plugin/views/filter/NumericFilter.php b/core/modules/views/src/Plugin/views/filter/NumericFilter.php index 7de7ddfb3a8d..783e2e6884ca 100644 --- a/core/modules/views/src/Plugin/views/filter/NumericFilter.php +++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php @@ -18,6 +18,9 @@ class NumericFilter extends FilterPluginBase implements FilterOperatorsInterface */ protected $alwaysMultiple = TRUE; + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -192,6 +195,9 @@ public function operatorOptions($which = 'title') { return $options; } + /** + * Gets the operators that have a given number of values. + */ protected function operatorValues($values = 1) { $options = []; foreach ($this->operators() as $id => $info) { @@ -333,6 +339,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } + /** + * {@inheritdoc} + */ public function query() { $this->ensureMyTable(); $field = "$this->tableAlias.$this->realField"; @@ -364,10 +373,16 @@ protected function opBetween($field) { } } + /** + * Filters by a simple operator. + */ protected function opSimple($field) { $this->query->addWhere($this->options['group'], $field, $this->value['value'], $this->operator); } + /** + * Adds a where clause for the operation, 'EMPTY'. + */ protected function opEmpty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; @@ -399,6 +414,9 @@ protected function opNotRegex($field) { $this->query->addWhere($this->options['group'], $field, $this->value['value'], 'NOT REGEXP'); } + /** + * {@inheritdoc} + */ public function adminSummary() { if ($this->isAGroup()) { return $this->t('grouped'); diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php index fb6c55cb4413..a647cedf8336 100644 --- a/core/modules/views/src/Plugin/views/filter/StringFilter.php +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php @@ -65,6 +65,9 @@ public static function create(ContainerInterface $container, array $configuratio ); } + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -219,6 +222,9 @@ public function operatorOptions($which = 'title') { return $options; } + /** + * {@inheritdoc} + */ public function adminSummary() { if ($this->isAGroup()) { return $this->t('grouped'); @@ -238,6 +244,9 @@ public function adminSummary() { return $output; } + /** + * Gets the operators that have a given number of values. + */ protected function operatorValues($values = 1) { $options = []; foreach ($this->operators() as $id => $info) { @@ -357,11 +366,17 @@ public function opEqual($field) { $this->query->addWhere($this->options['group'], $field, $this->value, $this->operator()); } + /** + * Adds a where clause for the operation, 'LIKE'. + */ protected function opContains($field) { $operator = $this->getConditionOperator('LIKE'); $this->query->addWhere($this->options['group'], $field, '%' . $this->connection->escapeLike($this->value) . '%', $operator); } + /** + * Adds a where clause for the operation, 'contains'. + */ protected function opContainsWord($field) { $where = $this->operator == 'word' ? $this->query->getConnection()->condition('OR') : $this->query->getConnection()->condition('AND'); @@ -395,31 +410,49 @@ protected function opContainsWord($field) { $this->query->addWhere($this->options['group'], $where); } + /** + * Adds a where clause for the operation, 'starts with'. + */ protected function opStartsWith($field) { $operator = $this->getConditionOperator('LIKE'); $this->query->addWhere($this->options['group'], $field, $this->connection->escapeLike($this->value) . '%', $operator); } + /** + * Adds a where clause for the operation, 'not starts with'. + */ protected function opNotStartsWith($field) { $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhere($this->options['group'], $field, $this->connection->escapeLike($this->value) . '%', $operator); } + /** + * Adds a where clause for the operation, 'ends with'. + */ protected function opEndsWith($field) { $operator = $this->getConditionOperator('LIKE'); $this->query->addWhere($this->options['group'], $field, '%' . $this->connection->escapeLike($this->value), $operator); } + /** + * Adds a where clause for the operation, 'not ends with'. + */ protected function opNotEndsWith($field) { $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhere($this->options['group'], $field, '%' . $this->connection->escapeLike($this->value), $operator); } + /** + * Adds a where clause for the operation, 'not LIKE'. + */ protected function opNotLike($field) { $operator = $this->getConditionOperator('NOT LIKE'); $this->query->addWhere($this->options['group'], $field, '%' . $this->connection->escapeLike($this->value) . '%', $operator); } + /** + * Adds a where clause for the operation, 'shorter than'. + */ protected function opShorterThan($field) { $placeholder = $this->placeholder(); // Type cast the argument to an integer because the SQLite database driver @@ -427,6 +460,9 @@ protected function opShorterThan($field) { $this->query->addWhereExpression($this->options['group'], "LENGTH($field) < $placeholder", [$placeholder => (int) $this->value]); } + /** + * Adds a where clause for the operation, 'longer than'. + */ protected function opLongerThan($field) { $placeholder = $this->placeholder(); // Type cast the argument to an integer because the SQLite database driver @@ -454,6 +490,9 @@ protected function opNotRegex($field) { $this->query->addWhere($this->options['group'], $field, $this->value, 'NOT REGEXP'); } + /** + * Adds a where clause for the operation, 'EMPTY'. + */ protected function opEmpty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php index f59c465da8c5..6b0b0385fca6 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php @@ -20,6 +20,9 @@ )] class StaticTest extends AccessPluginBase { + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); $options['access'] = ['default' => FALSE]; diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index c50f67f2d5fd..d123062f3dec 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -73,6 +73,11 @@ <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/> <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/> </rule> + <rule ref="Drupal.Commenting.FunctionComment.Missing"> + <include-pattern>core/modules/*/Plugin/views/filter/*</include-pattern> + <exclude-pattern>*/tests/*</exclude-pattern> + </rule> + <rule ref="Drupal.Commenting.FunctionComment.MissingParamType"> <include-pattern>core/lib/Component/*</include-pattern> </rule> -- GitLab