Fix phpstan errors
This commit is contained in:
parent
af83b3c431
commit
229cc62b03
8 changed files with 16 additions and 17 deletions
|
@ -27,7 +27,7 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
|||
|
||||
$nodeIds = $query->execute();
|
||||
|
||||
/** @var NodeInterface[] */
|
||||
/** @var DailyEmail[] */
|
||||
$nodes = $nodeStorage->loadMultiple($nodeIds);
|
||||
|
||||
return DailyEmails::fromEmails($nodes);
|
||||
|
|
|
@ -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<positive-int, NodeInterface> $emails
|
||||
* @param array<positive-int, DailyEmail> $emails
|
||||
*/
|
||||
private function __construct(
|
||||
private array $emails,
|
||||
|
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue