Skip to content
Snippets Groups Projects
Commit fcc0e787 authored by Alex Pott's avatar Alex Pott Committed by Marcos Cano
Browse files

Issue #3499648: Fix PHPStan and make code quality checks fail

parent f07d557f
No related branches found
No related tags found
1 merge request!96Fix PHPStan
Pipeline #395650 failed
......@@ -34,3 +34,11 @@ phpunit:
- 'sed -i "s/core_version_requirement.*/core_version_requirement: \^10||\^11/" web/modules/contrib/**/*.info.yml'
variables:
SYMFONY_DEPRECATIONS_HELPER: "disabled"
#
# Linting jobs are passing so any issue that breaks them should fix them.
#
phpcs:
allow_failure: false
phpstan:
allow_failure: false
# Configuration file for PHPStan static code checking, see https://phpstan.org .
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: 1
treatPhpDocTypesAsCertain: false
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
- "#^Unsafe usage of new static#"
......@@ -241,10 +241,11 @@ class ListUsageController extends ControllerBase {
continue;
}
$field_definitions = $this->entityFieldManager->getFieldDefinitions($source_type, $source_entity->bundle());
$default_langcode = $source_entity->language()->getId();
$used_in = [];
$revisions = [];
if ($source_entity instanceof RevisionableInterface) {
$default_revision_id = $source_entity->getRevisionId();
$default_langcode = $source_entity->language()->getId();
$revisions = [];
foreach (array_reverse($records) as $record) {
[
'source_vid' => $source_vid,
......@@ -257,7 +258,6 @@ class ListUsageController extends ControllerBase {
$revisions[$revision_group][$source_langcode] = $field_name;
}
$used_in = [];
foreach ($revision_groups as $index => $label) {
if (!empty($revisions[$index])) {
$used_in[] = $this->summariseRevisionGroup($default_langcode, $label, $revisions[$index]);
......
......@@ -402,9 +402,6 @@ abstract class EntityUsageTrackBase extends PluginBase implements EntityUsageTra
* The public file directory path.
*/
protected function publicFileDirectory() {
if (!$this->publicFileDirectory) {
$this->publicFileDirectory = \Drupal::service('stream_wrapper.public')->getDirectoryPath();
}
return $this->publicFileDirectory;
}
......
......@@ -148,7 +148,7 @@ class EntityUsageTest extends EntityKernelTestBase {
$this->assertEquals($expected_source_list, $real_source_list);
// Test the limit parameter.
unset($expected_source_list[$source_entity->getEntityTypeId()][2]);
unset($expected_source_list[$source_entity->getEntityTypeId()][(string) $source_entity->id()]);
$real_source_list = $entity_usage->listSources($target_entity, TRUE, 1);
$this->assertEquals($expected_source_list, $real_source_list);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment