From aec67504dd6a78cf566c311b7dcede50acfbbe82 Mon Sep 17 00:00:00 2001 From: Tiago Siqueira Date: Fri, 3 Jun 2022 11:22:36 +0200 Subject: [PATCH] Revert necessary changes to fix PHPStan issues --- .github/workflows/codingStandards.yml | 2 +- .../filter/FollowTaxonomyViewsFilter.php | 20 +++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codingStandards.yml b/.github/workflows/codingStandards.yml index 61a8af12722..238c52b2067 100644 --- a/.github/workflows/codingStandards.yml +++ b/.github/workflows/codingStandards.yml @@ -66,7 +66,7 @@ jobs: run: sudo update-alternatives --set php /usr/bin/php8.0 - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: composer install --prefer-dist --no-progress diff --git a/modules/social_features/social_follow_taxonomy/src/Plugin/views/filter/FollowTaxonomyViewsFilter.php b/modules/social_features/social_follow_taxonomy/src/Plugin/views/filter/FollowTaxonomyViewsFilter.php index 43be4933248..f42c099fafc 100644 --- a/modules/social_features/social_follow_taxonomy/src/Plugin/views/filter/FollowTaxonomyViewsFilter.php +++ b/modules/social_features/social_follow_taxonomy/src/Plugin/views/filter/FollowTaxonomyViewsFilter.php @@ -146,24 +146,10 @@ protected function valueForm(&$form, FormStateInterface $form_state): void { if (!$term->isPublished() && !$this->currentUser->hasPermission('administer taxonomy')) { continue; } - // There is a PHPStan error: - // --------------------------------------------------------------- - // Parameter #2 $times of function str_repeat expects int, - // Drupal\Core\Field\FieldItemListInterface given. - // --------------------------------------------------------------- - // The property 'depth' is adding to the term in - // TermStorage::loadTree(), this is why we can't load it with the - // usual methods. - // Typecasting directly for $term->depth is not solve this error. - // So, to fix it we need to determine term depth with another - // approach. - // @todo Load the term's depth in the right way when it will be - // possible - $parents = $this->entityTypeManager->getStorage('taxonomy_term')->loadParents((int) $term->id()); - // The number of parents determines the current depth. - $depth = count($parents); $choice = new \stdClass(); - $choice->option = [$term->id() => str_repeat('-', $depth) . $this->entityRepository->getTranslationFromContext($term)->label()]; + + // @phpstan-ignore-next-line + $choice->option = [$term->id() => str_repeat('-', $term->depth) . $this->entityRepository->getTranslationFromContext($term)->label()]; $options[] = $choice; } }