diff --git a/modules/opd_daily_emails/src/DailyEmailNodeRepository.php b/modules/opd_daily_emails/src/DailyEmailNodeRepository.php index 90d2be71e..4caf528ae 100644 --- a/modules/opd_daily_emails/src/DailyEmailNodeRepository.php +++ b/modules/opd_daily_emails/src/DailyEmailNodeRepository.php @@ -27,7 +27,7 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface { $nodeIds = $query->execute(); - /** @var NodeInterface[] */ + /** @var DailyEmail[] */ $nodes = $nodeStorage->loadMultiple($nodeIds); return DailyEmails::fromEmails($nodes); diff --git a/modules/opd_daily_emails/src/DailyEmails.php b/modules/opd_daily_emails/src/DailyEmails.php index 232b7f043..f42226386 100644 --- a/modules/opd_daily_emails/src/DailyEmails.php +++ b/modules/opd_daily_emails/src/DailyEmails.php @@ -17,12 +17,15 @@ final class DailyEmails implements \Countable { return array_values($this->emails)[0]; } + /** + * @param DailyEmail[] $emails + */ public static function fromEmails(array $emails): self { return new self($emails); } /** - * @param array $emails + * @param array $emails */ private function __construct( private array $emails, diff --git a/modules/opd_daily_emails/tests/src/Functional/CallToActionTest.php b/modules/opd_daily_emails/tests/src/Functional/CallToActionTest.php index 756e88a9d..2082d43da 100644 --- a/modules/opd_daily_emails/tests/src/Functional/CallToActionTest.php +++ b/modules/opd_daily_emails/tests/src/Functional/CallToActionTest.php @@ -36,8 +36,12 @@ final class CallToActionTest extends ExistingSiteBase { $email->set('title', 'Updated'); $email->save(); + $value = $email->get('field_daily_email_cta')->getValue(); + assert(is_array($value)); + assert(isset($value[0]['target_id'])); + $this->assertSame( - actual: $email->get('field_daily_email_cta')->getValue()[0]['target_id'], + actual: $value[0]['target_id'], expected: $cta->id(), ); } diff --git a/modules/opd_daily_emails/tests/src/Functional/DailyEmailTokenTest.php b/modules/opd_daily_emails/tests/src/Functional/DailyEmailTokenTest.php index e4461afd9..13ccb6bf7 100644 --- a/modules/opd_daily_emails/tests/src/Functional/DailyEmailTokenTest.php +++ b/modules/opd_daily_emails/tests/src/Functional/DailyEmailTokenTest.php @@ -23,17 +23,17 @@ class DailyEmailTokenTest extends BrowserTestBase { public function test_the_token_returns_the_number_of_published_daily_emails(): void { $this->createDailyEmailNode( isPublished: TRUE, - title: $this->randomString(), + title: 'a', ); $this->createDailyEmailNode( isPublished: FALSE, - title: $this->randomString(), + title: 'b', ); $this->createDailyEmailNode( isPublished: TRUE, - title: $this->randomString(), + title: 'c', ); $this->assertToken( diff --git a/modules/opd_podcast/src/Guests.php b/modules/opd_podcast/src/Guests.php index 6f163dfca..e46d2d4a9 100644 --- a/modules/opd_podcast/src/Guests.php +++ b/modules/opd_podcast/src/Guests.php @@ -19,7 +19,7 @@ final class Guests implements \Countable, \IteratorAggregate, \Stringable { return sprintf('%s %s %s', $this->first()->getName(), t('and'), $this->get(1)->getName()); } - return strval($this->first()->getName()); + return strval($this->first()?->getName()); } public function count(): int { @@ -48,7 +48,7 @@ final class Guests implements \Countable, \IteratorAggregate, \Stringable { Assert::allIsInstanceOf($guests, Guest::class); } - private function get(int $offset): ?Guest { + private function get(int $offset): Guest { return $this->guests[$offset]; } diff --git a/modules/opd_presentations/src/Events.php b/modules/opd_presentations/src/Events.php index a0266724b..252bb9631 100644 --- a/modules/opd_presentations/src/Events.php +++ b/modules/opd_presentations/src/Events.php @@ -35,9 +35,6 @@ readonly final class Events implements \Countable, \IteratorAggregate { ->filter(fn (Event $event): bool => $event->isPast()); } - /** - * @param non-empty-string[] $dates - */ public static function fromDateStrings(string ...$dates): self { $events = array_map( array: $dates, diff --git a/modules/opd_presentations/src/PresentationCounter.php b/modules/opd_presentations/src/PresentationCounter.php index 263032e6e..6d7753c46 100644 --- a/modules/opd_presentations/src/PresentationCounter.php +++ b/modules/opd_presentations/src/PresentationCounter.php @@ -9,8 +9,6 @@ use Drupal\node\NodeInterface; final class PresentationCounter { - private array $presentations; - public function __construct(private EntityTypeManagerInterface $entityTypeManager) { } @@ -24,6 +22,7 @@ final class PresentationCounter { $nodeIds = $query->execute(); + /** @var Presentation[] */ $presentations = $nodeStorage->loadMultiple($nodeIds); return array_reduce( diff --git a/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php b/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php index 7dc5e1d77..843a5addc 100644 --- a/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php +++ b/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php @@ -16,10 +16,6 @@ trait PresentationCreationTrait { use EntityCreationTrait; use NodeCreationTrait; - /** - * @param Event[] $events - * @param bool $isPublished - */ private function createPresentation(Events $events, bool $isPublished = TRUE): Presentation { $presentation = $this->createNode([ 'field_events' => $events->toEvents(),