From 35b700c29febf1461864f9b102726f6f186408d3 Mon Sep 17 00:00:00 2001 From: Pablo Urrea <paurca@gmail.com> Date: Fri, 21 Feb 2025 11:22:05 +0100 Subject: [PATCH] Issue #3508229: Fix PHP 8.4 implicit nullable deprecation --- src/Tree/EntityTreeBuilder.php | 13 +++++++++---- src/Tree/TaxonomyTreeBuilder.php | 13 +++++++++---- src/Tree/TreeBuilderInterface.php | 9 +++++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Tree/EntityTreeBuilder.php b/src/Tree/EntityTreeBuilder.php index c701c99..52a063a 100644 --- a/src/Tree/EntityTreeBuilder.php +++ b/src/Tree/EntityTreeBuilder.php @@ -35,14 +35,19 @@ class EntityTreeBuilder implements TreeBuilderInterface { * * @param string $entityType * The type of the entity. - * * @param string $bundleID * The bundle ID. + * @param string|null $langCode + * The language code. + * @param int $parent + * The parent entity ID. + * @param int|null $max_depth + * The maximum depth of the tree. * * @return array * All entities in the entity bundle. */ - public function loadTree(string $entityType, string $bundleID, string $langCode = NULL, int $parent = 0, int $max_depth = NULL) { + public function loadTree(string $entityType, string $bundleID, ?string $langCode = NULL, int $parent = 0, ?int $max_depth = NULL) { if ($this->hasAccess()) { if ($bundleID === '*') { // Load all entities regardless bundles. @@ -148,14 +153,14 @@ class EntityTreeBuilder implements TreeBuilderInterface { /** * Check if a user has the access to the tree. * - * @param \Drupal\Core\Session\AccountProxyInterface $user + * @param \Drupal\Core\Session\AccountProxyInterface|null $user * The user object to check. * * @return bool * If the user has the access to the tree return TRUE, * otherwise return FALSE. */ - private function hasAccess(AccountProxyInterface $user = NULL) { + private function hasAccess(?AccountProxyInterface $user = NULL) { // Check current user as default. if (empty($user)) { $user = \Drupal::currentUser(); diff --git a/src/Tree/TaxonomyTreeBuilder.php b/src/Tree/TaxonomyTreeBuilder.php index b106379..8e2ad26 100644 --- a/src/Tree/TaxonomyTreeBuilder.php +++ b/src/Tree/TaxonomyTreeBuilder.php @@ -34,14 +34,19 @@ class TaxonomyTreeBuilder implements TreeBuilderInterface { * * @param string $entityType * The type of the entity. - * * @param string $bundleID * The bundle ID. + * @param string|null $langCode + * The language code. + * @param int $parent + * The parent entity ID. + * @param int|null $max_depth + * The maximum depth of the tree. * * @return array * All entities in the entity bundle. */ - public function loadTree(string $entityType, string $bundleID, string $langCode = NULL, int $parent = 0, int $max_depth = NULL) { + public function loadTree(string $entityType, string $bundleID, ?string $langCode = NULL, int $parent = 0, ?int $max_depth = NULL) { // Setup the language code for this tree. // Use current language by default. if (empty($langCode)) { @@ -126,14 +131,14 @@ class TaxonomyTreeBuilder implements TreeBuilderInterface { /** * Check if a user has the access to the tree. * - * @param \Drupal\Core\Session\AccountProxyInterface $user + * @param \Drupal\Core\Session\AccountProxyInterface|null $user * The user object to check. * * @return bool * If the user has the access to the tree return TRUE, * otherwise return FALSE. */ - private function hasAccess(AccountProxyInterface $user = NULL) { + private function hasAccess(?AccountProxyInterface $user = NULL) { // Check current user as default. if (empty($user)) { $user = \Drupal::currentUser(); diff --git a/src/Tree/TreeBuilderInterface.php b/src/Tree/TreeBuilderInterface.php index 356f9c1..5a01e0e 100644 --- a/src/Tree/TreeBuilderInterface.php +++ b/src/Tree/TreeBuilderInterface.php @@ -14,14 +14,19 @@ interface TreeBuilderInterface { * * @param string $entityType * The type of the entity. - * * @param string $bundleID * The bundle ID. + * @param string|null $langCode + * The language code. + * @param int $parent + * The parent entity ID. + * @param int|null $max_depth + * The maximum depth of the tree. * * @return array * All entities in the entity bundle. */ - public function loadTree(string $entityType, string $bundleID, string $langCode = NULL, int $parent = 0, int $max_depth = NULL); + public function loadTree(string $entityType, string $bundleID, ?string $langCode = NULL, int $parent = 0, ?int $max_depth = NULL); /** * Create a tree node. -- GitLab