Add phpstan
This commit is contained in:
parent
90e8e68fa8
commit
cc557aa0fc
8 changed files with 30 additions and 8 deletions
|
@ -3,11 +3,14 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Drupal\Core\Render\BubbleableMetadata;
|
use Drupal\Core\Render\BubbleableMetadata;
|
||||||
|
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||||
use Drupal\opd_daily_emails\Collection\DailyEmailCollection;
|
use Drupal\opd_daily_emails\Collection\DailyEmailCollection;
|
||||||
use Drupal\opd_daily_emails\Repository\DailyEmailNodeRepository;
|
use Drupal\opd_daily_emails\Repository\DailyEmailNodeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_token_info().
|
* Implements hook_token_info().
|
||||||
|
*
|
||||||
|
* @return array{tokens: array<non-empty-string, array{description: TranslatableMarkup, name: TranslatableMarkup}[]>, types: array<non-empty-string, array{description: TranslatableMarkup, name: TranslatableMarkup}>}
|
||||||
*/
|
*/
|
||||||
function opd_daily_emails_token_info(): array {
|
function opd_daily_emails_token_info(): array {
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
|
@ -34,8 +37,14 @@ function opd_daily_emails_token_info(): array {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_tokens().
|
* Implements hook_tokens().
|
||||||
|
*
|
||||||
|
* @param array<non-empty-string, non-empty-string> $tokens
|
||||||
|
* @param array<non-empty-string, mixed> $data
|
||||||
|
* @param array<non-empty-string, mixed> $options
|
||||||
|
*
|
||||||
|
* @return array<non-empty-string, mixed>
|
||||||
*/
|
*/
|
||||||
function opd_daily_emails_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleableMetadata) : array {
|
function opd_daily_emails_tokens(string $type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleableMetadata) : array {
|
||||||
$replacements = [];
|
$replacements = [];
|
||||||
|
|
||||||
if ($type === 'opd-daily-emails') {
|
if ($type === 'opd-daily-emails') {
|
||||||
|
|
|
@ -8,6 +8,9 @@ use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
final class DailyEmailCollection implements \Countable {
|
final class DailyEmailCollection implements \Countable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<positive-int, NodeInterface> $emails
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private array $emails,
|
private array $emails,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
||||||
$query->accessCheck(TRUE);
|
$query->accessCheck(TRUE);
|
||||||
|
|
||||||
$nodeIds = $query->execute();
|
$nodeIds = $query->execute();
|
||||||
|
|
||||||
|
/** @var NodeInterface[] */
|
||||||
$nodes = $nodeStorage->loadMultiple($nodeIds);
|
$nodes = $nodeStorage->loadMultiple($nodeIds);
|
||||||
|
|
||||||
return new DailyEmailCollection($nodes);
|
return new DailyEmailCollection($nodes);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class DailyEmailTokenTest extends BrowserTestBase {
|
||||||
|
|
||||||
public $defaultTheme = 'stark';
|
public $defaultTheme = 'stark';
|
||||||
|
|
||||||
public static $modules = [
|
protected static $modules = [
|
||||||
'node',
|
'node',
|
||||||
'opd_daily_emails',
|
'opd_daily_emails',
|
||||||
];
|
];
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class DailyEmailNodeRepositoryTest extends EntityKernelTestBase {
|
||||||
|
|
||||||
use DailyEmailTestTrait;
|
use DailyEmailTestTrait;
|
||||||
|
|
||||||
public static $modules = [
|
protected static $modules = [
|
||||||
'node',
|
'node',
|
||||||
'opd_daily_emails',
|
'opd_daily_emails',
|
||||||
];
|
];
|
||||||
|
@ -32,11 +32,7 @@ final class DailyEmailNodeRepositoryTest extends EntityKernelTestBase {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$repository = $this->container->get(DailyEmailNodeRepository::class);
|
$repository = $this->container->get(DailyEmailNodeRepository::class);
|
||||||
|
assert($repository instanceof DailyEmailRepositoryInterface);
|
||||||
$this->assertInstanceOf(
|
|
||||||
actual: $repository,
|
|
||||||
expected: DailyEmailRepositoryInterface::class,
|
|
||||||
);
|
|
||||||
|
|
||||||
$emails = $repository->getAll();
|
$emails = $repository->getAll();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ trait DailyEmailTestTrait {
|
||||||
|
|
||||||
use NodeCreationTrait;
|
use NodeCreationTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<non-empty-string, non-empty-string|int> $options
|
||||||
|
*/
|
||||||
protected function createDailyEmailNode(array $options): NodeInterface {
|
protected function createDailyEmailNode(array $options): NodeInterface {
|
||||||
return $this->createNode(array_merge(
|
return $this->createNode(array_merge(
|
||||||
$options,
|
$options,
|
||||||
|
|
|
@ -4,6 +4,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
use Drupal\node\NodeInterface;
|
use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<non-empty-string, array<non-empty-string, array{}>> $links
|
||||||
|
* @param array<non-empty-string, mixed> $context
|
||||||
|
*/
|
||||||
function opd_podcast_node_links_alter(array &$links, NodeInterface $entity, array &$context): void {
|
function opd_podcast_node_links_alter(array &$links, NodeInterface $entity, array &$context): void {
|
||||||
if ($entity->bundle() !== 'podcast_episode') {
|
if ($entity->bundle() !== 'podcast_episode') {
|
||||||
return;
|
return;
|
||||||
|
|
5
phpstan.neon.dist
Normal file
5
phpstan.neon.dist
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
parameters:
|
||||||
|
level: max
|
||||||
|
paths:
|
||||||
|
- modules
|
||||||
|
- themes
|
Loading…
Add table
Add a link
Reference in a new issue