Skip to content
Snippets Groups Projects
Commit 8be8e726 authored by Bram Driesen's avatar Bram Driesen Committed by Kalle Vuorjoki
Browse files

Issue #3426825 by mparker17, BramDriesen, sokru: Increase PHPstan level to 2

parent a72ab138
Branches
Tags
1 merge request!41Issue #3426825: Increase PHPstan level to 2
Pipeline #121338 passed
......@@ -46,8 +46,8 @@ include:
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'
variables:
_PHPUNIT_CONCURRENT: '1'
# Define an 'elasticsearch' service, running ElasticSearch 8.
# See also:
......
parameters:
ignoreErrors:
-
message: """
#^Call to deprecated method calculatePluginDependencies\\(\\) of class Drupal\\\\elasticsearch_connector\\\\Plugin\\\\search_api\\\\backend\\\\ElasticSearchBackend\\:
in search_api\\:8\\.x\\-1\\.16 and is removed from search_api\\:2\\.0\\.0\\.
Add \\\\Drupal\\\\Core\\\\Plugin\\\\PluginDependencyTrait manually for your class if
you need it\\.$#
"""
- # See https://www.drupal.org/project/search_api/issues/3428603.
message: "#^Call to an undefined method Drupal\\\\search_api\\\\Query\\\\ConditionGroupInterface\\:\\:__toString\\(\\).$#"
count: 1
path: src/Plugin/search_api/backend/ElasticSearchBackend.php
path: src/
# This error comes from code copied directly from search_api_opensearch, and
# seems to be related to something that either was planned but never built,
# or used to exist, but was partly removed. It's unclear if removing this
# code will have an adverse effect on how search queries are built: let us
# leave this until we have better query test coverage.
-
message: "#^Cannot unset offset 'fields' on array\\{from\\: mixed, size\\: mixed, sort\\?\\: non\\-empty\\-array, query\\?\\: non\\-empty\\-array\\}\\.$#"
count: 1
path: src/SearchAPI/Query/QueryParamBuilder.php
# This error comes from code copied directly from search_api_opensearch, and
# seems to be related to something that either was planned but never built,
# or used to exist, but was partly removed. It's unclear if removing this
# code will have an adverse effect on how search queries are built: let us
# leave this until we have better query test coverage.
-
message: "#^Cannot unset offset 'post_filter' on array\\{from\\: mixed, size\\: mixed, sort\\?\\: non\\-empty\\-array, query\\?\\: non\\-empty\\-array\\}\\.$#"
count: 1
path: src/SearchAPI/Query/QueryParamBuilder.php
# This error comes from code copied directly from search_api_opensearch, and
# seems to be related to something that either was planned but never built,
# or used to exist, but was partly removed. It's unclear if removing this
# code will have an adverse effect on how search queries are built: let us
# leave this until we have better query test coverage.
-
message: "#^Variable \\$body in empty\\(\\) always exists and is not falsy\\.$#"
count: 1
path: src/SearchAPI/Query/QueryParamBuilder.php
# This error comes from code copied directly from search_api_opensearch, and
# seems to be related to something that either was planned but never built,
# or used to exist, but was partly removed. It's unclear if removing this
# code will have an adverse effect on how search queries are built: let us
# leave this until we have better query test coverage.
-
message: "#^Variable \\$fields in empty\\(\\) is never defined\\.$#"
count: 1
......
parameters:
# @todo Increase to level 2 https://www.drupal.org/project/elasticsearch_connector/issues/3426825
level: 1
level: 2
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
- "#^Unsafe usage of new static#"
# Ignore PHPUnit Prophecy class reflection errors.
- "#^Call to an undefined method Prophecy#"
paths:
- .
......
......@@ -37,7 +37,9 @@ class ElasticSearchBackend extends BackendPluginBase implements PluginFormInterf
use DependencySerializationTrait {
__sleep as traitSleep;
}
use PluginDependencyTrait;
use PluginDependencyTrait {
getPluginDependencies as traitGetPluginDependencies;
}
/**
* Auto fuzziness setting.
......@@ -205,7 +207,7 @@ class ElasticSearchBackend extends BackendPluginBase implements PluginFormInterf
$connector_id = $this->configuration['connector'];
if (isset($connector_id)) {
$connector = $this->connectorPluginManager->createInstance($connector_id, $this->configuration['connector_config']);
if ($connector instanceof PluginFormInterface) {
if ($connector instanceof ElasticSearchConnectorInterface) {
$form_state->set('connector', $connector_id);
// Attach the ElasticSearch connector plugin configuration form.
$connector_form_state = SubformState::createForSubform($form['connector_config'], $form, $form_state);
......@@ -213,7 +215,9 @@ class ElasticSearchBackend extends BackendPluginBase implements PluginFormInterf
// Modify the backend plugin configuration container element.
$form['connector_config']['#type'] = 'details';
$form['connector_config']['#title'] = $this->t('Configure %plugin ElasticSearch connector', ['%plugin' => $connector->getLabel()]);
$form['connector_config']['#title'] = $this->t('Configure %plugin ElasticSearch connector', [
'%plugin' => $connector->getLabel(),
]);
$form['connector_config']['#description'] = $connector->getDescription();
$form['connector_config']['#open'] = TRUE;
}
......@@ -401,7 +405,7 @@ class ElasticSearchBackend extends BackendPluginBase implements PluginFormInterf
* {@inheritdoc}
*/
public function calculateDependencies() {
return $this->calculatePluginDependencies($this->getConnector());
return $this->traitGetPluginDependencies($this->getConnector());
}
/**
......
......@@ -26,7 +26,6 @@ class SearchParamBuilderTest extends UnitTestCase {
* @covers ::buildSearchParams
*/
public function testBuildSearchParams() {
$backend = $this->prophesize(ElasticSearchBackend::class);
$backend->getFuzziness()
->willReturn('auto');
......@@ -76,7 +75,6 @@ class SearchParamBuilderTest extends UnitTestCase {
];
$this->assertEquals($expected, $searchParams);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment