Skip to content

Commit

Permalink
Revert necessary changes to fix PHPStan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tbsiqueira committed Jun 3, 2022
1 parent 7044fd0 commit aec6750
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codingStandards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit aec6750

Please sign in to comment.