Skip to content

Commit 3af03bb

Browse files
PHP 8.4 Support (#4)
FIX Implicitly marking parameter $langcode as nullable is deprecated, the explicit nullable type must be used instead
1 parent 1c549e3 commit 3af03bb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Traits/EntityTranslationTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ trait EntityTranslationTrait {
1919
*
2020
* @param \Drupal\Core\Entity\EntityInterface $entity
2121
* An entity that might contain a translation.
22-
* @param string $langcode
22+
* @param string|null $langcode
2323
* The langcode in which to translate, leave empty to use current langcode.
2424
* @param bool $required
2525
* If an entity is not translated, returns NULL if set to TRUE.
2626
*
2727
* @return \Drupal\Core\Entity\EntityInterface|null
2828
* The translated entity or null.
2929
*/
30-
public function translateEntity(EntityInterface $entity, string $langcode = NULL, bool $required = FALSE) : ?EntityInterface {
30+
public function translateEntity(EntityInterface $entity, ?string $langcode = NULL, bool $required = FALSE) : ?EntityInterface {
3131
if ($required) {
3232
$returnEntity = NULL;
3333
}
@@ -57,15 +57,15 @@ public function translateEntity(EntityInterface $entity, string $langcode = NULL
5757
*
5858
* @param array $entities
5959
* An array of entities.
60-
* @param string $langcode
60+
* @param string|null $langcode
6161
* The langcode in which to translate, leave empty to use current langcode.
6262
* @param bool $removeUntranslated
6363
* Removes entities that are not translated.
6464
*
6565
* @return array
6666
* An array of translated entities
6767
*/
68-
public function translateEntities(array $entities, string $langcode = NULL, bool $removeUntranslated = FALSE) : array {
68+
public function translateEntities(array $entities, ?string $langcode = NULL, bool $removeUntranslated = FALSE) : array {
6969
// Get the langcode first so we don't have to fetch it in the loop.
7070
if (!$langcode) {
7171
$langcode = \Drupal::languageManager()
@@ -91,4 +91,4 @@ public function translateEntities(array $entities, string $langcode = NULL, bool
9191
return $entities;
9292
}
9393

94-
}
94+
}

0 commit comments

Comments
 (0)