From b58b03839217bcb00145aae417f0fca27fa91af9 Mon Sep 17 00:00:00 2001 From: Christian Fritsch Date: Fri, 12 Jul 2024 15:44:53 +0200 Subject: [PATCH] Add strict typing everywhere, use php attributes and property promotion * Add strict typing everywhere, use php attributes and property promotion * Fix * Moar in tests * Rename fieldContext --------- Co-authored-by: Christian Fritsch --- .../ThunderArticleBreadcrumbBuilder.php | 69 ++----------------- .../Form/NodeRevisionRevertDefaultForm.php | 22 +----- .../Plugin/Derivative/DynamicLocalTasks.php | 32 ++------- .../src/ThunderNodeFormHelper.php | 14 +--- .../src/GraphQL/DecoratableTypeResolver.php | 4 +- .../src/GraphQL/MediaTypeResolver.php | 2 +- .../src/GraphQL/PagesTypeResolver.php | 2 +- .../src/GraphQL/ParagraphsTypeResolver.php | 2 +- .../GraphQL/DataProducer/EntityLinks.php | 26 +++---- .../GraphQL/DataProducer/FocalPoint.php | 39 ++++------- .../DataProducer/MenuLinksActiveTrail.php | 30 ++------ .../Plugin/GraphQL/DataProducer/MetaTags.php | 48 ++++--------- .../DataProducer/ThunderBreadcrumb.php | 10 +-- .../ThunderEntityListProducerBase.php | 36 +++------- .../ThunderEntitySubRequestBase.php | 60 +++++----------- .../GraphQL/DataProducer/ThunderImage.php | 46 +++---------- .../GraphQL/DataProducer/ThunderJsonLd.php | 8 +-- .../GraphQL/DataProducer/ThunderLanguage.php | 6 +- .../GraphQL/DataProducer/ThunderRedirect.php | 40 +++-------- .../Plugin/GraphQL/Schema/ThunderSchema.php | 6 +- .../ThunderSchemaExtensionPluginBase.php | 4 +- .../src/Traits/ResolverHelperTrait.php | 15 ++-- .../src/Wrappers/EntityListResponse.php | 16 ++--- .../Wrappers/EntityListResponseInterface.php | 4 +- .../src/Functional/CacheInvalidationTest.php | 7 +- .../src/Functional/RedirectSchemaTest.php | 3 +- .../DataProducer/EntitiesWithTermTest.php | 5 +- .../DataProducer/ThunderMetatagsTest.php | 3 +- .../src/Form/ConfigurationForm.php | 26 +------ .../Plugin/ImageEffect/AutoAspectEffect.php | 15 ++-- .../src/ThunderTaxonomyPermissions.php | 10 +-- .../FieldWidget/ModerationStateWidget.php | 15 ++-- .../src/ThunderWorkflowFormHelper.php | 56 ++------------- .../ThunderNodeEditBreadcrumbBuilder.php | 2 +- src/Installer/Form/ModuleConfigureForm.php | 12 ++-- src/Plugin/Block/ThunderPoweredByBlock.php | 12 ++-- .../src/MockHttpClientMiddleware.php | 13 +--- tests/src/Functional/BreadcrumbTest.php | 2 - .../Functional/InstalledConfigurationTest.php | 10 +-- .../Installer/ThunderInstallerGermanTest.php | 2 +- .../Installer/ThunderInstallerTest.php | 2 +- .../Integration/ContentTranslationTest.php | 2 +- tests/src/Functional/ModuleUninstallTest.php | 2 +- .../FunctionalJavascript/ChannelsTagsTest.php | 2 +- .../Integration/DiffTest.php | 4 +- .../Integration/ParagraphSplitTest.php | 4 +- .../Integration/ParagraphsPasteTest.php | 2 +- .../MetaInformationTest.php | 15 ++-- .../ThunderJavascriptTestBase.php | 4 +- tests/src/Kernel/MetatagTest.php | 3 +- 50 files changed, 220 insertions(+), 554 deletions(-) diff --git a/modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php b/modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php index 0aa578d63..1f4ee5d9c 100644 --- a/modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php +++ b/modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php @@ -10,6 +10,7 @@ use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\taxonomy\TermStorageInterface; /** * Class to define the menu_link breadcrumb builder. @@ -17,68 +18,12 @@ class ThunderArticleBreadcrumbBuilder implements BreadcrumbBuilderInterface { use StringTranslationTrait; - /** - * The router request context. - * - * @var \Drupal\Core\Routing\RequestContext - */ - protected $context; - - /** - * The menu link access service. - * - * @var \Drupal\Core\Access\AccessManagerInterface - */ - protected $accessManager; - - /** - * The dynamic router service. - * - * @var \Symfony\Component\Routing\Matcher\RequestMatcherInterface - */ - protected $router; - - /** - * The dynamic router service. - * - * @var \Drupal\Core\PathProcessor\InboundPathProcessorInterface - */ - protected $pathProcessor; - - /** - * Site configFactory object. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** - * The title resolver. - * - * @var \Drupal\Core\Controller\TitleResolverInterface - */ - protected $titleResolver; - - /** - * The current user object. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $currentUser; - - /** - * The entity repository service. - * - * @var \Drupal\Core\Entity\EntityRepositoryInterface - */ - protected $entityRepository; - /** * The taxonomy storage. * * @var \Drupal\taxonomy\TermStorageInterface */ - protected $termStorage; + protected TermStorageInterface $termStorage; /** * Constructs the ThunderArticleBreadcrumbBuilder. @@ -93,10 +38,8 @@ class ThunderArticleBreadcrumbBuilder implements BreadcrumbBuilderInterface { * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - public function __construct(EntityTypeManagerInterface $entityTypeManager, EntityRepositoryInterface $entityRepository, ConfigFactoryInterface $configFactory) { - $this->entityRepository = $entityRepository; + public function __construct(EntityTypeManagerInterface $entityTypeManager, protected readonly EntityRepositoryInterface $entityRepository, protected readonly ConfigFactoryInterface $configFactory) { $this->termStorage = $entityTypeManager->getStorage('taxonomy_term'); - $this->configFactory = $configFactory; } /** @@ -106,7 +49,7 @@ public function applies(RouteMatchInterface $route_match): bool { // This breadcrumb apply only for all articles. $parameters = $route_match->getParameters()->all(); if (($route_match->getRouteName() === 'entity.node.canonical') && is_object($parameters['node'])) { - return $parameters['node']->getType() == 'article'; + return $parameters['node']->getType() === 'article'; } return FALSE; } @@ -125,7 +68,7 @@ public function build(RouteMatchInterface $route_match): Breadcrumb { // Add all parent forums to breadcrumbs. /** @var \Drupal\taxonomy\TermInterface|NULL $term */ - $term = !empty($node->field_channel) ? $node->field_channel->entity : NULL; + $term = $node->field_channel->entity ?? NULL; $links = []; if ($term) { @@ -139,7 +82,7 @@ public function build(RouteMatchInterface $route_match): Breadcrumb { $links[] = Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' => $term->id()]); } } - if (!$links || '/' . $links[0]->getUrl()->getInternalPath() != $this->configFactory->get('system.site')->get('page.front')) { + if (!$links || '/' . $links[0]->getUrl()->getInternalPath() !== $this->configFactory->get('system.site')->get('page.front')) { array_unshift($links, Link::createFromRoute($this->t('Home'), '')); } diff --git a/modules/thunder_article/src/Form/NodeRevisionRevertDefaultForm.php b/modules/thunder_article/src/Form/NodeRevisionRevertDefaultForm.php index 458a72c50..170b95684 100644 --- a/modules/thunder_article/src/Form/NodeRevisionRevertDefaultForm.php +++ b/modules/thunder_article/src/Form/NodeRevisionRevertDefaultForm.php @@ -22,33 +22,17 @@ class NodeRevisionRevertDefaultForm extends ConfirmFormBase { * * @var \Drupal\node\NodeInterface */ - protected $revision; - - /** - * The date formatter service. - * - * @var \Drupal\Core\Datetime\DateFormatterInterface - */ - protected $dateFormatter; - - /** - * The time service. - * - * @var \Drupal\Component\Datetime\TimeInterface - */ - protected $time; + protected NodeInterface $revision; /** * Constructs a new NodeRevisionRevertForm. * - * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter + * @param \Drupal\Core\Datetime\DateFormatterInterface $dateFormatter * The date formatter service. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ - public function __construct(DateFormatterInterface $date_formatter, TimeInterface $time) { - $this->dateFormatter = $date_formatter; - $this->time = $time; + public function __construct(protected readonly DateFormatterInterface $dateFormatter, protected readonly TimeInterface $time) { } /** diff --git a/modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php b/modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php index 6397b73a2..760f5d474 100644 --- a/modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php +++ b/modules/thunder_article/src/Plugin/Derivative/DynamicLocalTasks.php @@ -18,44 +18,20 @@ class DynamicLocalTasks extends DeriverBase implements ContainerDeriverInterface use StringTranslationTrait; - /** - * The module handler service. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * The route provider service. - * - * @var \Drupal\Core\Routing\RouteProviderInterface - */ - protected $routeProvider; - - /** - * The config factory service. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - /** * Creates an DynamicLocalTasks object. * * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The translation manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler * The module handler service. - * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider + * @param \Drupal\Core\Routing\RouteProviderInterface $routeProvider * The route provider service. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. */ - public function __construct(TranslationInterface $string_translation, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ConfigFactoryInterface $config_factory) { + public function __construct(TranslationInterface $string_translation, protected readonly ModuleHandlerInterface $moduleHandler, protected readonly RouteProviderInterface $routeProvider, protected readonly ConfigFactoryInterface $configFactory) { $this->stringTranslation = $string_translation; - $this->moduleHandler = $module_handler; - $this->routeProvider = $route_provider; - $this->configFactory = $config_factory; } /** diff --git a/modules/thunder_article/src/ThunderNodeFormHelper.php b/modules/thunder_article/src/ThunderNodeFormHelper.php index 555df2096..8f648f0dd 100644 --- a/modules/thunder_article/src/ThunderNodeFormHelper.php +++ b/modules/thunder_article/src/ThunderNodeFormHelper.php @@ -10,23 +10,15 @@ /** * Base for handler for node add/edit forms. */ -class ThunderNodeFormHelper implements ContainerInjectionInterface { - - /** - * The theme manager. - * - * @var \Drupal\Core\Theme\ThemeManagerInterface - */ - protected ThemeManagerInterface $themeManager; +readonly class ThunderNodeFormHelper implements ContainerInjectionInterface { /** * Constructs a ThunderNodeFormHelper object. * - * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager + * @param \Drupal\Core\Theme\ThemeManagerInterface $themeManager * The theme manager. */ - final public function __construct(ThemeManagerInterface $theme_manager) { - $this->themeManager = $theme_manager; + final public function __construct(protected ThemeManagerInterface $themeManager) { } /** diff --git a/modules/thunder_gqls/src/GraphQL/DecoratableTypeResolver.php b/modules/thunder_gqls/src/GraphQL/DecoratableTypeResolver.php index c14e852f4..8b6720938 100644 --- a/modules/thunder_gqls/src/GraphQL/DecoratableTypeResolver.php +++ b/modules/thunder_gqls/src/GraphQL/DecoratableTypeResolver.php @@ -58,7 +58,7 @@ public function __construct(?self $resolver) { * @return string|null * The GraphQL type name or NULL if this resolver could not determine it. */ - abstract protected function resolve($object) : ?string; + abstract protected function resolve(mixed $object) : ?string; /** * Allows this type resolver to be called by the GraphQL library. @@ -75,7 +75,7 @@ abstract protected function resolve($object) : ?string; * @throws \RuntimeException * When a type was passed for which no type resolver exists in the chain. */ - public function __invoke($object) : string { + public function __invoke(mixed $object) : string { $type = $this->resolve($object); if ($type !== NULL) { return $type; diff --git a/modules/thunder_gqls/src/GraphQL/MediaTypeResolver.php b/modules/thunder_gqls/src/GraphQL/MediaTypeResolver.php index b5efeacc1..c0bc10beb 100644 --- a/modules/thunder_gqls/src/GraphQL/MediaTypeResolver.php +++ b/modules/thunder_gqls/src/GraphQL/MediaTypeResolver.php @@ -15,7 +15,7 @@ class MediaTypeResolver extends DecoratableTypeResolver { /** * {@inheritdoc} */ - protected function resolve($object) : ?string { + protected function resolve(mixed $object) : ?string { if ($object instanceof MediaInterface) { return 'Media' . $this->mapBundleToSchemaName($object->bundle()); } diff --git a/modules/thunder_gqls/src/GraphQL/PagesTypeResolver.php b/modules/thunder_gqls/src/GraphQL/PagesTypeResolver.php index 010d9b565..a2c20da32 100644 --- a/modules/thunder_gqls/src/GraphQL/PagesTypeResolver.php +++ b/modules/thunder_gqls/src/GraphQL/PagesTypeResolver.php @@ -17,7 +17,7 @@ class PagesTypeResolver extends DecoratableTypeResolver { /** * {@inheritdoc} */ - protected function resolve($object) : ?string { + protected function resolve(mixed $object) : ?string { if ($object instanceof NodeInterface || $object instanceof TermInterface || $object instanceof UserInterface) { if ($object->bundle() === 'page') { return 'BasicPage'; diff --git a/modules/thunder_gqls/src/GraphQL/ParagraphsTypeResolver.php b/modules/thunder_gqls/src/GraphQL/ParagraphsTypeResolver.php index 0b9b4f2c6..0fa823841 100644 --- a/modules/thunder_gqls/src/GraphQL/ParagraphsTypeResolver.php +++ b/modules/thunder_gqls/src/GraphQL/ParagraphsTypeResolver.php @@ -15,7 +15,7 @@ class ParagraphsTypeResolver extends DecoratableTypeResolver { /** * {@inheritdoc} */ - protected function resolve($object) : ?string { + protected function resolve(mixed $object) : ?string { if ($object instanceof ParagraphInterface) { return 'Paragraph' . $this->mapBundleToSchemaName($object->bundle()); } diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/EntityLinks.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/EntityLinks.php index 3a3d50ab6..3c0c042c3 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/EntityLinks.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/EntityLinks.php @@ -28,23 +28,16 @@ */ class EntityLinks extends DataProducerPluginBase implements ContainerFactoryPluginInterface { - /** - * The rendering service. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('renderer') ); } @@ -54,21 +47,20 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. */ public function __construct( array $configuration, - string $pluginId, - $pluginDefinition, - RendererInterface $renderer, + string $plugin_id, + $plugin_definition, + protected readonly RendererInterface $renderer, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->renderer = $renderer; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/FocalPoint.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/FocalPoint.php index a26ab0fd0..34e7040e8 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/FocalPoint.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/FocalPoint.php @@ -3,6 +3,7 @@ namespace Drupal\thunder_gqls\Plugin\GraphQL\DataProducer; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\file\FileInterface; @@ -34,32 +35,18 @@ class FocalPoint extends DataProducerPluginBase implements ContainerFactoryPlugi * * @var \Drupal\Core\Config\ImmutableConfig */ - protected $config; - - /** - * The focal point manager service. - * - * @var \Drupal\focal_point\FocalPointManagerInterface - */ - protected $focalPointManager; - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; + protected ImmutableConfig $config; /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('config.factory'), $container->get('focal_point.manager'), $container->get('module_handler') @@ -71,9 +58,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. @@ -84,16 +71,14 @@ public static function create(ContainerInterface $container, array $configuratio */ public function __construct( array $configuration, - string $pluginId, - $pluginDefinition, + string $plugin_id, + $plugin_definition, ConfigFactoryInterface $configFactory, - FocalPointManagerInterface $focalPointManager, - ModuleHandlerInterface $moduleHandler, + protected readonly FocalPointManagerInterface $focalPointManager, + protected readonly ModuleHandlerInterface $moduleHandler, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); + parent::__construct($configuration, $plugin_id, $plugin_definition); $this->config = $configFactory->get('focal_point.settings'); - $this->focalPointManager = $focalPointManager; - $this->moduleHandler = $moduleHandler; } /** diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MenuLinksActiveTrail.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MenuLinksActiveTrail.php index 1faf60209..c127ca5cc 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MenuLinksActiveTrail.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MenuLinksActiveTrail.php @@ -39,30 +39,16 @@ class MenuLinksActiveTrail extends DataProducerPluginBase implements ContainerFactoryPluginInterface { use DependencySerializationTrait; - /** - * The menu link tree. - * - * @var \Drupal\Core\Menu\MenuLinkTreeInterface - */ - protected $menuLinkTree; - - /** - * The menu link tree. - * - * @var \Drupal\Core\Menu\MenuLinkManagerInterface - */ - protected $menuLinkManager; - /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('menu.link_tree'), $container->get('plugin.manager.menu.link') ); @@ -73,9 +59,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Menu\MenuLinkTreeInterface $menuLinkTree * The menu link tree service. @@ -84,10 +70,8 @@ public static function create(ContainerInterface $container, array $configuratio * * @codeCoverageIgnore */ - public function __construct(array $configuration, $pluginId, $pluginDefinition, MenuLinkTreeInterface $menuLinkTree, MenuLinkManagerInterface $menuLinkManager) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->menuLinkTree = $menuLinkTree; - $this->menuLinkManager = $menuLinkManager; + public function __construct(array $configuration, $plugin_id, $plugin_definition, protected readonly MenuLinkTreeInterface $menuLinkTree, protected readonly MenuLinkManagerInterface $menuLinkManager) { + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MetaTags.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MetaTags.php index 9eacc739f..10e896ee5 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MetaTags.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/MetaTags.php @@ -39,37 +39,16 @@ class MetaTags extends DataProducerPluginBase implements ContainerFactoryPluginInterface { use DataFetcherTrait; - /** - * The rendering service. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** - * The metatag manager service. - * - * @var \Drupal\metatag\MetatagManager - */ - protected $metatagManager; - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('renderer'), $container->get('metatag.manager'), $container->get('module_handler') @@ -81,9 +60,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. @@ -94,16 +73,13 @@ public static function create(ContainerInterface $container, array $configuratio */ public function __construct( array $configuration, - string $pluginId, - $pluginDefinition, - RendererInterface $renderer, - MetatagManager $metatagManager, - ModuleHandlerInterface $moduleHandler, + string $plugin_id, + $plugin_definition, + protected readonly RendererInterface $renderer, + protected readonly MetatagManager $metatagManager, + protected readonly ModuleHandlerInterface $moduleHandler, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->renderer = $renderer; - $this->metatagManager = $metatagManager; - $this->moduleHandler = $moduleHandler; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** @@ -119,7 +95,7 @@ public function __construct( * @return array * Normalized metatags. */ - public function resolve($value, ?string $type, RefinableCacheableDependencyInterface $metadata): array { + public function resolve(mixed $value, ?string $type, RefinableCacheableDependencyInterface $metadata): array { if ($value instanceof ContentEntityInterface) { $context = new RenderContext(); $result = $this->renderer->executeInRenderContext($context, function () use ($value): array { diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderBreadcrumb.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderBreadcrumb.php index 08aad9e5b..348a7d95f 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderBreadcrumb.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderBreadcrumb.php @@ -32,22 +32,22 @@ class ThunderBreadcrumb extends ThunderEntitySubRequestBase { /** * The breadcrumb manager. * - * @var \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface + * @var \Drupal\Core\Breadcrumb\BreadcrumbManager */ - protected $breadcrumbManager; + protected BreadcrumbManager $breadcrumbManager; /** * The route match service. * * @var \Drupal\Core\Routing\CurrentRouteMatch */ - protected $currentRouteMatch; + protected CurrentRouteMatch $currentRouteMatch; /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { - $producer = parent::create($container, $configuration, $pluginId, $pluginDefinition); + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $producer = parent::create($container, $configuration, $plugin_id, $plugin_definition); $producer->setCurrentRouteMatch($container->get('current_route_match')); $producer->setBreadcrumbManager($container->get('breadcrumb')); return $producer; diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntityListProducerBase.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntityListProducerBase.php index 610700ab2..9e3b37e59 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntityListProducerBase.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntityListProducerBase.php @@ -16,21 +16,7 @@ */ abstract class ThunderEntityListProducerBase extends DataProducerPluginBase implements ContainerFactoryPluginInterface { - public const MAX_ITEMS = 100; - - /** - * The entity type manager service. - * - * @var \Drupal\Core\Entity\EntityTypeManager - */ - protected $entityTypeManager; - - /** - * The current user. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $currentUser; + public const int MAX_ITEMS = 100; /** * {@inheritdoc} @@ -50,25 +36,23 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param array $pluginDefinition + * @param array $plugin_definition * The plugin definition array. * @param \Drupal\Core\Entity\EntityTypeManager $entityTypeManager * The entity type manager service. - * @param \Drupal\Core\Session\AccountInterface $current_user + * @param \Drupal\Core\Session\AccountInterface $currentUser * The current user. */ public function __construct( array $configuration, - string $pluginId, - array $pluginDefinition, - EntityTypeManager $entityTypeManager, - AccountInterface $current_user, + string $plugin_id, + array $plugin_definition, + protected readonly EntityTypeManager $entityTypeManager, + protected readonly AccountInterface $currentUser, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->entityTypeManager = $entityTypeManager; - $this->currentUser = $current_user; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** @@ -149,7 +133,7 @@ protected function query( if (!empty($sort['field'])) { if (!empty($sort['direction']) && strtolower( $sort['direction'] - ) == 'desc') { + ) === 'desc') { $direction = 'DESC'; } else { diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntitySubRequestBase.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntitySubRequestBase.php index 950bf5f06..709fab4c4 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntitySubRequestBase.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderEntitySubRequestBase.php @@ -18,37 +18,16 @@ */ abstract class ThunderEntitySubRequestBase extends DataProducerPluginBase implements ContainerFactoryPluginInterface { - /** - * The HTTP kernel service. - * - * @var \Symfony\Component\HttpKernel\HttpKernelInterface - */ - protected $httpKernel; - - /** - * The current request. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $currentRequest; - - /** - * The rendering service. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('http_kernel'), $container->get('request_stack')->getCurrentRequest(), $container->get('renderer') @@ -60,9 +39,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel * The HTTP kernel service. @@ -73,22 +52,19 @@ public static function create(ContainerInterface $container, array $configuratio */ public function __construct( array $configuration, - string $pluginId, - $pluginDefinition, - HttpKernelInterface $httpKernel, - Request $currentRequest, - RendererInterface $renderer, + string $plugin_id, + $plugin_definition, + protected readonly HttpKernelInterface $httpKernel, + protected readonly Request $currentRequest, + protected readonly RendererInterface $renderer, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->httpKernel = $httpKernel; - $this->currentRequest = $currentRequest; - $this->renderer = $renderer; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** * {@inheritdoc} */ - public function resolveField(FieldContext $fieldContext) { + public function resolveField(FieldContext $field) { $contextValues = $this->getContextValues(); if (!isset($contextValues['path'])) { @@ -96,7 +72,7 @@ public function resolveField(FieldContext $fieldContext) { } $url = $this->currentRequest->getSchemeAndHttpHost() . $contextValues['path']; - $request = $this->createRequest($this->currentRequest, $url, $fieldContext); + $request = $this->createRequest($this->currentRequest, $url, $field); $response = $this->httpKernel->handle($request, HttpKernelInterface::SUB_REQUEST); if ($response instanceof SubRequestResponse) { @@ -116,13 +92,13 @@ public function resolveField(FieldContext $fieldContext) { * The current main request. * @param string $url * The url to run the subrequest on. - * @param \Drupal\graphql\GraphQL\Execution\FieldContext $fieldContext + * @param \Drupal\graphql\GraphQL\Execution\FieldContext $field * The field context. * * @return \Symfony\Component\HttpFoundation\Request * The request object. */ - protected function createRequest(Request $current, string $url, FieldContext $fieldContext) { + protected function createRequest(Request $current, string $url, FieldContext $field): Request { $request = Request::create( $url, 'GET', @@ -132,7 +108,7 @@ protected function createRequest(Request $current, string $url, FieldContext $fi $current->server->all() ); - $request->attributes->set('_graphql_subrequest', function (CacheableMetadata $cacheableMetadata) use ($fieldContext) { + $request->attributes->set('_graphql_subrequest', function (CacheableMetadata $cacheableMetadata) use ($field) { if (!method_exists($this, 'resolve')) { throw new \LogicException('Missing data producer resolve method.'); } @@ -143,12 +119,12 @@ protected function createRequest(Request $current, string $url, FieldContext $fi [$this, 'resolve'], array_values(array_merge($contextValues, [ $cacheableMetadata, - $fieldContext, + $field, ])) )); if (!$context->isEmpty()) { - $fieldContext->addCacheableDependency($context->pop()); + $field->addCacheableDependency($context->pop()); } return $result ?? ''; diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderImage.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderImage.php index 8c839f525..f3ff086db 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderImage.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderImage.php @@ -34,37 +34,16 @@ */ class ThunderImage extends DataProducerPluginBase implements ContainerFactoryPluginInterface { - /** - * The rendering service. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** - * The image factory. - * - * @var \Drupal\Core\Image\ImageFactory - */ - protected $imageFactory; - - /** - * The file URL generator service. - * - * @var \Drupal\Core\File\FileUrlGeneratorInterface - */ - protected $fileUrlGenerator; - /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, - $pluginId, - $pluginDefinition, + $plugin_id, + $plugin_definition, $container->get('renderer'), $container->get('image.factory'), $container->get('file_url_generator') @@ -76,9 +55,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration array. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. @@ -91,16 +70,13 @@ public static function create(ContainerInterface $container, array $configuratio */ public function __construct( array $configuration, - $pluginId, - $pluginDefinition, - RendererInterface $renderer, - ImageFactory $imageFactory, - FileUrlGeneratorInterface $fileUrlGenerator, + $plugin_id, + $plugin_definition, + protected readonly RendererInterface $renderer, + protected readonly ImageFactory $imageFactory, + protected readonly FileUrlGeneratorInterface $fileUrlGenerator, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->renderer = $renderer; - $this->imageFactory = $imageFactory; - $this->fileUrlGenerator = $fileUrlGenerator; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderJsonLd.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderJsonLd.php index 9bb67b68d..4e777cf1a 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderJsonLd.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderJsonLd.php @@ -35,22 +35,22 @@ class ThunderJsonLd extends ThunderEntitySubRequestBase { * * @var \Drupal\metatag\MetatagManager|null */ - protected $metatagManager; + protected ?MetatagManager $metatagManager; /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - protected $moduleHandler; + protected ModuleHandlerInterface $moduleHandler; /** * {@inheritdoc} * * @codeCoverageIgnore */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { - $producer = parent::create($container, $configuration, $pluginId, $pluginDefinition); + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $producer = parent::create($container, $configuration, $plugin_id, $plugin_definition); $producer->setMetatagManager($container->get('metatag.manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)); $producer->setModuleHandler($container->get('module_handler')); return $producer; diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderLanguage.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderLanguage.php index 5adf5cd85..520bc0fb2 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderLanguage.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderLanguage.php @@ -38,13 +38,13 @@ class ThunderLanguage extends ThunderEntitySubRequestBase { * * @var \Drupal\Core\Language\LanguageManagerInterface */ - protected $languageManager; + protected LanguageManagerInterface $languageManager; /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { - $producer = parent::create($container, $configuration, $pluginId, $pluginDefinition); + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $producer = parent::create($container, $configuration, $plugin_id, $plugin_definition); $producer->setLanguageManager($container->get('language_manager')); return $producer; } diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderRedirect.php b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderRedirect.php index cad408b5e..b0582d6ba 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderRedirect.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/ThunderRedirect.php @@ -32,27 +32,6 @@ */ class ThunderRedirect extends DataProducerPluginBase implements ContainerFactoryPluginInterface { - /** - * Optional redirect module repository. - * - * @var \Drupal\redirect\RedirectRepository|null - */ - protected $redirectRepository; - - /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** - * The path validator. - * - * @var \Drupal\Core\Path\PathValidatorInterface - */ - protected $pathValidator; - /** * {@inheritdoc} * @@ -74,9 +53,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @param array $configuration * The plugin configuration. - * @param string $pluginId + * @param string $plugin_id * The plugin id. - * @param mixed $pluginDefinition + * @param mixed $plugin_definition * The plugin definition. * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager * The language manager. @@ -89,16 +68,13 @@ public static function create(ContainerInterface $container, array $configuratio */ public function __construct( array $configuration, - $pluginId, - $pluginDefinition, - LanguageManagerInterface $languageManager, - PathValidatorInterface $pathValidator, - ?RedirectRepository $redirectRepository = NULL, + $plugin_id, + $plugin_definition, + protected readonly LanguageManagerInterface $languageManager, + protected readonly PathValidatorInterface $pathValidator, + protected readonly ?RedirectRepository $redirectRepository = NULL, ) { - parent::__construct($configuration, $pluginId, $pluginDefinition); - $this->languageManager = $languageManager; - $this->pathValidator = $pathValidator; - $this->redirectRepository = $redirectRepository; + parent::__construct($configuration, $plugin_id, $plugin_definition); } /** diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/Schema/ThunderSchema.php b/modules/thunder_gqls/src/Plugin/GraphQL/Schema/ThunderSchema.php index 1afaa4f5a..aaa2f1340 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/Schema/ThunderSchema.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/Schema/ThunderSchema.php @@ -25,7 +25,7 @@ class ThunderSchema extends ComposableSchema { use ResolverHelperTrait; - public const REQUIRED_EXTENSIONS = [ + public const array REQUIRED_EXTENSIONS = [ 'thunder_pages', 'thunder_media', 'thunder_paragraphs', @@ -36,7 +36,7 @@ class ThunderSchema extends ComposableSchema { * * @var \Drupal\graphql\Plugin\DataProducerPluginManager */ - protected $dataProducerManager; + protected DataProducerPluginManager $dataProducerManager; /** * {@inheritdoc} @@ -113,7 +113,7 @@ protected function getExtensions(): array { public function buildConfigurationForm(array $form, FormStateInterface $form_state): array { $form = parent::buildConfigurationForm($form, $form_state); foreach (Element::children($form['extensions']) as $extension) { - if (in_array($extension, static::REQUIRED_EXTENSIONS)) { + if (in_array($extension, static::REQUIRED_EXTENSIONS, TRUE)) { $form['extensions'][$extension]['#disabled'] = TRUE; $form['extensions'][$extension]['#value'] = TRUE; } diff --git a/modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderSchemaExtensionPluginBase.php b/modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderSchemaExtensionPluginBase.php index d5fe25b9e..075603ba5 100644 --- a/modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderSchemaExtensionPluginBase.php +++ b/modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderSchemaExtensionPluginBase.php @@ -24,14 +24,14 @@ abstract class ThunderSchemaExtensionPluginBase extends SdlSchemaExtensionPlugin * * @var \Drupal\graphql\Plugin\DataProducerPluginManager */ - protected $dataProducerManager; + protected DataProducerPluginManager $dataProducerManager; /** * The entity type manager service. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityTypeManager; + protected EntityTypeManagerInterface $entityTypeManager; /** * {@inheritdoc} diff --git a/modules/thunder_gqls/src/Traits/ResolverHelperTrait.php b/modules/thunder_gqls/src/Traits/ResolverHelperTrait.php index d09fbca9e..8a8b94ce7 100644 --- a/modules/thunder_gqls/src/Traits/ResolverHelperTrait.php +++ b/modules/thunder_gqls/src/Traits/ResolverHelperTrait.php @@ -2,8 +2,11 @@ namespace Drupal\thunder_gqls\Traits; +use Drupal\graphql\GraphQL\Resolver\Composite; use Drupal\graphql\GraphQL\Resolver\ResolverInterface; use Drupal\graphql\GraphQL\ResolverBuilder; +use Drupal\graphql\GraphQL\ResolverRegistryInterface; +use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerProxy; /** * Helper functions for field resolvers. @@ -15,14 +18,14 @@ trait ResolverHelperTrait { * * @var \Drupal\graphql\GraphQL\ResolverBuilder */ - protected $builder; + protected ResolverBuilder $builder; /** * ResolverRegistryInterface. * * @var \Drupal\graphql\GraphQL\ResolverRegistryInterface */ - protected $registry; + protected ResolverRegistryInterface $registry; /** * Add field resolver to registry, if it does not already exist. @@ -60,7 +63,7 @@ protected function createResolverBuilder(): void { * @return \Drupal\graphql\GraphQL\Resolver\Composite * The field data producer. */ - public function fromEntityReference(string $field, ResolverInterface $entity = NULL, bool $multiValue = TRUE) { + public function fromEntityReference(string $field, ResolverInterface $entity = NULL, bool $multiValue = TRUE): Composite { return $this->builder->compose( $this->builder->produce('entity_reference') ->map('field', $this->builder->fromValue($field)) @@ -85,7 +88,7 @@ public function fromEntityReference(string $field, ResolverInterface $entity = N * @return \Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerProxy * The field data producer. */ - public function fromEntityReferenceRevisions(string $field, $entity = NULL) { + public function fromEntityReferenceRevisions(string $field, ?ResolverInterface $entity = NULL): DataProducerProxy { return $this->builder->produce('entity_reference_revisions') ->map('field', $this->builder->fromValue($field)) ->map('entity', $entity ?: $this->builder->fromParent()) @@ -117,7 +120,7 @@ public function addSimpleCallbackFields(string $type, array $fields): void { * @return \Drupal\graphql\GraphQL\Resolver\ResolverInterface * The resolved entity. */ - public function fromRoute(ResolverInterface $path) { + public function fromRoute(ResolverInterface $path): ResolverInterface { return $this->builder->compose( $this->builder->produce('route_load') ->map('path', $path), @@ -138,7 +141,7 @@ public function fromRoute(ResolverInterface $path) { * @return string * Returns the mapped bundle name. */ - protected function mapBundleToSchemaName(string $bundleName) { + protected function mapBundleToSchemaName(string $bundleName): string { return str_replace('_', '', ucwords($bundleName, '_')); } diff --git a/modules/thunder_gqls/src/Wrappers/EntityListResponse.php b/modules/thunder_gqls/src/Wrappers/EntityListResponse.php index d2502ac23..90318c64d 100644 --- a/modules/thunder_gqls/src/Wrappers/EntityListResponse.php +++ b/modules/thunder_gqls/src/Wrappers/EntityListResponse.php @@ -8,14 +8,7 @@ /** * The thunder entity list response class. */ -class EntityListResponse implements EntityListResponseInterface { - - /** - * The query interface. - * - * @var \Drupal\Core\Entity\Query\QueryInterface - */ - protected $query; +readonly class EntityListResponse implements EntityListResponseInterface { /** * EntityListResponse constructor. @@ -23,8 +16,7 @@ class EntityListResponse implements EntityListResponseInterface { * @param \Drupal\Core\Entity\Query\QueryInterface $query * The query interface. */ - public function __construct(QueryInterface $query) { - $this->query = $query; + public function __construct(protected QueryInterface $query) { } /** @@ -36,7 +28,7 @@ public function __construct(QueryInterface $query) { public function total(): int { $query = clone $this->query; $query->range(NULL, NULL)->count(); - return intval($query->execute()); + return (int) $query->execute(); } /** @@ -45,7 +37,7 @@ public function total(): int { * @return array|\GraphQL\Deferred * The entity list. */ - public function items() { + public function items(): array|Deferred { $result = $this->query->execute(); if (empty($result)) { return []; diff --git a/modules/thunder_gqls/src/Wrappers/EntityListResponseInterface.php b/modules/thunder_gqls/src/Wrappers/EntityListResponseInterface.php index a40b1c3a2..08d72be59 100644 --- a/modules/thunder_gqls/src/Wrappers/EntityListResponseInterface.php +++ b/modules/thunder_gqls/src/Wrappers/EntityListResponseInterface.php @@ -2,6 +2,8 @@ namespace Drupal\thunder_gqls\Wrappers; +use GraphQL\Deferred; + /** * The thunder entity list response class. */ @@ -21,6 +23,6 @@ public function total(): int; * @return array|\GraphQL\Deferred * The entity list. */ - public function items(); + public function items(): array|Deferred; } diff --git a/modules/thunder_gqls/tests/src/Functional/CacheInvalidationTest.php b/modules/thunder_gqls/tests/src/Functional/CacheInvalidationTest.php index d2589e910..df99386c9 100644 --- a/modules/thunder_gqls/tests/src/Functional/CacheInvalidationTest.php +++ b/modules/thunder_gqls/tests/src/Functional/CacheInvalidationTest.php @@ -2,6 +2,9 @@ namespace Drupal\Tests\thunder_gqls\Functional; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; + /** * Test cache invalidation of GraphQL requests. * @@ -14,14 +17,14 @@ class CacheInvalidationTest extends ThunderGqlsTestBase { * * @var \Drupal\Core\Config\ConfigFactoryInterface */ - protected $configFactory; + protected ConfigFactoryInterface $configFactory; /** * The entity type manager. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityTypeManager; + protected EntityTypeManagerInterface $entityTypeManager; /** * {@inheritdoc} diff --git a/modules/thunder_gqls/tests/src/Functional/RedirectSchemaTest.php b/modules/thunder_gqls/tests/src/Functional/RedirectSchemaTest.php index d26c16a5a..d7d9e1d1a 100644 --- a/modules/thunder_gqls/tests/src/Functional/RedirectSchemaTest.php +++ b/modules/thunder_gqls/tests/src/Functional/RedirectSchemaTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\thunder_gqls\Functional; use Drupal\Component\Serialization\Json; +use Drupal\node\NodeInterface; /** * Test the redirect endpoint. @@ -16,7 +17,7 @@ class RedirectSchemaTest extends ThunderGqlsTestBase { * * @var \Drupal\node\NodeInterface */ - protected $unpublishedEntity; + protected NodeInterface $unpublishedEntity; /** * {@inheritdoc} diff --git a/modules/thunder_gqls/tests/src/Kernel/DataProducer/EntitiesWithTermTest.php b/modules/thunder_gqls/tests/src/Kernel/DataProducer/EntitiesWithTermTest.php index a065cf9b4..d1ddd8161 100644 --- a/modules/thunder_gqls/tests/src/Kernel/DataProducer/EntitiesWithTermTest.php +++ b/modules/thunder_gqls/tests/src/Kernel/DataProducer/EntitiesWithTermTest.php @@ -8,6 +8,7 @@ use Drupal\node\Entity\NodeType; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\taxonomy\TermInterface; use Drupal\Tests\graphql\Kernel\GraphQLTestBase; /** @@ -22,12 +23,12 @@ class EntitiesWithTermTest extends GraphQLTestBase { * * @var \Drupal\taxonomy\TermInterface */ - protected $parent; + protected TermInterface $parent; /** * The taxonomy term reference field name. */ - protected const TAXONOMY_FIELD_NAME = 'taxonomy_field'; + protected const string TAXONOMY_FIELD_NAME = 'taxonomy_field'; /** * {@inheritdoc} diff --git a/modules/thunder_gqls/tests/src/Kernel/DataProducer/ThunderMetatagsTest.php b/modules/thunder_gqls/tests/src/Kernel/DataProducer/ThunderMetatagsTest.php index a261ac857..4885639bc 100644 --- a/modules/thunder_gqls/tests/src/Kernel/DataProducer/ThunderMetatagsTest.php +++ b/modules/thunder_gqls/tests/src/Kernel/DataProducer/ThunderMetatagsTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\thunder_gqls\Kernel\DataProducer; use Drupal\node\Entity\Node; +use Drupal\node\NodeInterface; use Drupal\Tests\graphql\Kernel\GraphQLTestBase; use Drupal\Tests\TestFileCreationTrait; @@ -20,7 +21,7 @@ class ThunderMetatagsTest extends GraphQLTestBase { * * @var \Drupal\node\NodeInterface */ - protected $node; + protected NodeInterface $node; /** * {@inheritdoc} diff --git a/modules/thunder_media/src/Form/ConfigurationForm.php b/modules/thunder_media/src/Form/ConfigurationForm.php index 00c9ccd95..563d1fcc1 100644 --- a/modules/thunder_media/src/Form/ConfigurationForm.php +++ b/modules/thunder_media/src/Form/ConfigurationForm.php @@ -4,20 +4,13 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Form\RedundantEditableConfigNamesTrait; /** * Configuration form for Thunder media settings. */ class ConfigurationForm extends ConfigFormBase { - - /** - * {@inheritdoc} - */ - protected function getEditableConfigNames(): array { - return [ - 'thunder_media.settings', - ]; - } + use RedundantEditableConfigNamesTrait; /** * {@inheritdoc} @@ -30,27 +23,14 @@ public function getFormId(): string { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state): array { - $config = $this->config('thunder_media.settings'); - $form['enable_filefield_remove_button'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable file field remove button'), '#description' => $this->t('Enable this checkbox to enable remove buttons for file fields on inline entity forms.'), - '#default_value' => $config->get('enable_filefield_remove_button'), + '#config_target' => 'thunder_media.settings:enable_filefield_remove_button', ]; return parent::buildForm($form, $form_state); } - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state): void { - parent::submitForm($form, $form_state); - - $this->config('thunder_media.settings') - ->set('enable_filefield_remove_button', $form_state->getValue('enable_filefield_remove_button')) - ->save(); - } - } diff --git a/modules/thunder_media/src/Plugin/ImageEffect/AutoAspectEffect.php b/modules/thunder_media/src/Plugin/ImageEffect/AutoAspectEffect.php index 359537a65..cf84560f4 100644 --- a/modules/thunder_media/src/Plugin/ImageEffect/AutoAspectEffect.php +++ b/modules/thunder_media/src/Plugin/ImageEffect/AutoAspectEffect.php @@ -5,18 +5,19 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\image\Attribute\ImageEffect; use Drupal\image\ConfigurableImageEffectBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Resizes an image resource. - * - * @ImageEffect( - * id = "thunder_media_auto_aspect", - * label = @Translation("Auto Aspect"), - * description = @Translation("Use different effects depending on whether the image is landscape of portrait shaped. This re-uses other preset definitions, and just chooses between them based on the rule.") - * ) */ +#[ImageEffect( + id: "thunder_media_auto_aspect", + label: new TranslatableMarkup("Auto Aspect"), + description: new TranslatableMarkup("Use different effects depending on whether the image is landscape of portrait shaped. This re-uses other preset definitions, and just chooses between them based on the rule."), +)] class AutoAspectEffect extends ConfigurableImageEffectBase { /** @@ -24,7 +25,7 @@ class AutoAspectEffect extends ConfigurableImageEffectBase { * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityTypeManager; + protected EntityTypeManagerInterface $entityTypeManager; /** * {@inheritdoc} diff --git a/modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php b/modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php index 818644a71..2b640c000 100644 --- a/modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php +++ b/modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php @@ -16,21 +16,13 @@ class ThunderTaxonomyPermissions implements ContainerInjectionInterface { use StringTranslationTrait; - /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - /** * Constructs a TaxonomyPermissions instance. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager * The entity type manager. */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { - $this->entityTypeManager = $entityTypeManager; + public function __construct(protected readonly EntityTypeManagerInterface $entityTypeManager) { } /** diff --git a/modules/thunder_workflow/src/Plugin/Field/FieldWidget/ModerationStateWidget.php b/modules/thunder_workflow/src/Plugin/Field/FieldWidget/ModerationStateWidget.php index 24d0ad65d..247cd2f34 100644 --- a/modules/thunder_workflow/src/Plugin/Field/FieldWidget/ModerationStateWidget.php +++ b/modules/thunder_workflow/src/Plugin/Field/FieldWidget/ModerationStateWidget.php @@ -3,8 +3,10 @@ namespace Drupal\thunder_workflow\Plugin\Field\FieldWidget; use Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget as CoreModerationStateWidget; +use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'thunder_moderation_state_default' widget. @@ -12,15 +14,12 @@ * Thunder provides its own moderation_state widget that only shows a list of * possible states to switch in. To display the current state is not part of * this widget. Thunder shows that in ThunderNodeFormHelper. - * - * @FieldWidget( - * id = "thunder_moderation_state_default", - * label = @Translation("Moderation state (Thunder)"), - * field_types = { - * "string" - * } - * ) */ +#[FieldWidget( + id: 'thunder_moderation_state_default', + label: new TranslatableMarkup('Moderation state (Thunder)'), + field_types: ['string'], +)] class ModerationStateWidget extends CoreModerationStateWidget { /** diff --git a/modules/thunder_workflow/src/ThunderWorkflowFormHelper.php b/modules/thunder_workflow/src/ThunderWorkflowFormHelper.php index 091662a10..dbf3fe8f2 100644 --- a/modules/thunder_workflow/src/ThunderWorkflowFormHelper.php +++ b/modules/thunder_workflow/src/ThunderWorkflowFormHelper.php @@ -24,20 +24,6 @@ class ThunderWorkflowFormHelper implements ContainerInjectionInterface { use StringTranslationTrait; - /** - * The current user. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected AccountInterface $currentUser; - - /** - * The messenger service. - * - * @var \Drupal\Core\Messenger\MessengerInterface - */ - protected MessengerInterface $messenger; - /** * The request object. * @@ -45,46 +31,18 @@ class ThunderWorkflowFormHelper implements ContainerInjectionInterface { */ protected Request $request; - /** - * The moderation information service. - * - * @var \Drupal\content_moderation\ModerationInformationInterface - */ - protected ModerationInformationInterface $moderationInfo; - - /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected EntityTypeManagerInterface $entityTypeManager; - - /** - * The theme manager. - * - * @var \Drupal\Core\Theme\ThemeManagerInterface - */ - protected ThemeManagerInterface $themeManager; - - /** - * The state transition validation service. - * - * @var \Drupal\content_moderation\StateTransitionValidationInterface - */ - protected StateTransitionValidationInterface $stateTransitionValidation; - /** * Constructs a NodeForm object. * - * @param \Drupal\Core\Session\AccountInterface $current_user + * @param \Drupal\Core\Session\AccountInterface $currentUser * The current user. * @param \Drupal\Core\Messenger\MessengerInterface $messenger * The messenger service. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack service. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager * The entity type manager. - * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager + * @param \Drupal\Core\Theme\ThemeManagerInterface $themeManager * The theme manager. * @param \Drupal\content_moderation\ModerationInformationInterface $moderationInfo * The moderation info service. The optionality is important @@ -92,14 +50,8 @@ class ThunderWorkflowFormHelper implements ContainerInjectionInterface { * @param \Drupal\content_moderation\StateTransitionValidationInterface $stateTransitionValidation * The state transition validation service. */ - final public function __construct(AccountInterface $current_user, MessengerInterface $messenger, RequestStack $requestStack, EntityTypeManagerInterface $entity_type_manager, ThemeManagerInterface $theme_manager, ModerationInformationInterface $moderationInfo, StateTransitionValidationInterface $stateTransitionValidation) { - $this->currentUser = $current_user; - $this->messenger = $messenger; + final public function __construct(protected readonly AccountInterface $currentUser, protected readonly MessengerInterface $messenger, RequestStack $requestStack, protected readonly EntityTypeManagerInterface $entityTypeManager, protected readonly ThemeManagerInterface $themeManager, protected readonly ModerationInformationInterface $moderationInfo, protected readonly StateTransitionValidationInterface $stateTransitionValidation) { $this->request = $requestStack->getCurrentRequest(); - $this->entityTypeManager = $entity_type_manager; - $this->themeManager = $theme_manager; - $this->moderationInfo = $moderationInfo; - $this->stateTransitionValidation = $stateTransitionValidation; } /** diff --git a/src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php b/src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php index 330f11c0e..cbd5d38b2 100644 --- a/src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php +++ b/src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php @@ -36,7 +36,7 @@ public function build(RouteMatchInterface $route_match): Breadcrumb { $links[] = Link::createFromRoute($this->t('Home'), ''); $links[] = Link::createFromRoute($this->t('Overview'), 'system.admin_content'); - if ($route_match->getRouteName() == 'node.add') { + if ($route_match->getRouteName() === 'node.add') { $links[] = Link::createFromRoute($this->t('Add content'), 'node.add_page'); } diff --git a/src/Installer/Form/ModuleConfigureForm.php b/src/Installer/Form/ModuleConfigureForm.php index 9de6125ac..623e6d58b 100644 --- a/src/Installer/Form/ModuleConfigureForm.php +++ b/src/Installer/Form/ModuleConfigureForm.php @@ -30,42 +30,42 @@ class ModuleConfigureForm extends FormBase { * * @var \Drupal\Core\Extension\ModuleExtensionList */ - protected $moduleExtensionList; + protected ModuleExtensionList $moduleExtensionList; /** * The module installer. * * @var \Drupal\Core\Extension\ModuleInstallerInterface */ - protected $moduleInstaller; + protected ModuleInstallerInterface $moduleInstaller; /** * The access manager service. * * @var \Drupal\Core\Access\AccessManagerInterface */ - protected $accessManager; + protected AccessManagerInterface $accessManager; /** * The module handler service. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - protected $moduleHandler; + protected ModuleHandlerInterface $moduleHandler; /** * The current user. * * @var \Drupal\Core\Session\AccountProxyInterface */ - protected $currentUser; + protected AccountProxyInterface $currentUser; /** * The permission handler service. * * @var \Drupal\user\PermissionHandlerInterface */ - protected $permissionHandler; + protected PermissionHandlerInterface $permissionHandler; /** * {@inheritdoc} diff --git a/src/Plugin/Block/ThunderPoweredByBlock.php b/src/Plugin/Block/ThunderPoweredByBlock.php index 34fefdd3d..da26247d3 100644 --- a/src/Plugin/Block/ThunderPoweredByBlock.php +++ b/src/Plugin/Block/ThunderPoweredByBlock.php @@ -2,16 +2,18 @@ namespace Drupal\thunder\Plugin\Block; +use Drupal\Core\Block\Attribute\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Provides a 'Powered by Thunder' block. - * - * @Block( - * id = "thunder_powered_by_block", - * admin_label = @Translation("Powered by Thunder") - * ) */ +#[Block( + id: "thunder_powered_by_block", + admin_label: new TranslatableMarkup("Powered by Thunder"), + category: new TranslatableMarkup("Footer") +)] class ThunderPoweredByBlock extends BlockBase { /** diff --git a/tests/modules/thunder_test_mock_request/src/MockHttpClientMiddleware.php b/tests/modules/thunder_test_mock_request/src/MockHttpClientMiddleware.php index 64707a0e0..babed8040 100644 --- a/tests/modules/thunder_test_mock_request/src/MockHttpClientMiddleware.php +++ b/tests/modules/thunder_test_mock_request/src/MockHttpClientMiddleware.php @@ -6,6 +6,7 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -18,14 +19,7 @@ class MockHttpClientMiddleware { * * @var \Symfony\Component\HttpFoundation\Request */ - protected $request; - - /** - * The state service. - * - * @var \Drupal\Core\State\StateInterface - */ - protected $state; + protected Request $request; /** * MockHttpClientMiddleware constructor. @@ -35,9 +29,8 @@ class MockHttpClientMiddleware { * @param \Drupal\Core\State\StateInterface $state * The state service. */ - public function __construct(RequestStack $requestStack, StateInterface $state) { + public function __construct(RequestStack $requestStack, protected readonly StateInterface $state) { $this->request = $requestStack->getCurrentRequest(); - $this->state = $state; } /** diff --git a/tests/src/Functional/BreadcrumbTest.php b/tests/src/Functional/BreadcrumbTest.php index 77c981a3f..728ef0d8d 100644 --- a/tests/src/Functional/BreadcrumbTest.php +++ b/tests/src/Functional/BreadcrumbTest.php @@ -11,8 +11,6 @@ * @group Thunder */ class BreadcrumbTest extends ThunderTestBase { - - use AssertBreadcrumbTrait; /** diff --git a/tests/src/Functional/InstalledConfigurationTest.php b/tests/src/Functional/InstalledConfigurationTest.php index b9a334188..bf03562b9 100644 --- a/tests/src/Functional/InstalledConfigurationTest.php +++ b/tests/src/Functional/InstalledConfigurationTest.php @@ -46,7 +46,7 @@ class InstalledConfigurationTest extends ThunderTestBase { * * @var array */ - protected static $ignoreCoreConfigs = [ + protected static array $ignoreCoreConfigs = [ 'checklistapi.progress.update_helper_checklist', 'system.site', 'core.extension', @@ -104,7 +104,7 @@ class InstalledConfigurationTest extends ThunderTestBase { * * @var array */ - protected static $ignoreConfigKeys = [ + protected static array $ignoreConfigKeys = [ // It's not exported in Yaml, so that new key is generated. 'scheduler.settings' => [ 'lightweight_cron_access_key' => TRUE, @@ -297,7 +297,7 @@ class InstalledConfigurationTest extends ThunderTestBase { * * @var string */ - public const CONFIG_PATH_SEPARATOR = '::'; + public const string CONFIG_PATH_SEPARATOR = '::'; /** * Ignore configuration list values. Path to key is separated by '::'. @@ -314,7 +314,7 @@ class InstalledConfigurationTest extends ThunderTestBase { * * @todo use this functionality for more strict "dependencies" checking. */ - protected static $ignoreConfigListValues = [ + protected static array $ignoreConfigListValues = [ 'user.role.editor' => [ 'permissions' => [ 'access tour', @@ -349,7 +349,7 @@ class InstalledConfigurationTest extends ThunderTestBase { * * @var array */ - protected static $ignoreConfigs = []; + protected static array $ignoreConfigs = []; /** * Set default theme for test. diff --git a/tests/src/Functional/Installer/ThunderInstallerGermanTest.php b/tests/src/Functional/Installer/ThunderInstallerGermanTest.php index 2699443f3..e18adb7c8 100644 --- a/tests/src/Functional/Installer/ThunderInstallerGermanTest.php +++ b/tests/src/Functional/Installer/ThunderInstallerGermanTest.php @@ -12,7 +12,7 @@ class ThunderInstallerGermanTest extends ThunderInstallerTest { /** * {@inheritdoc} */ - protected $knownWarnings = 0; + protected int $knownWarnings = 0; /** * {@inheritdoc} diff --git a/tests/src/Functional/Installer/ThunderInstallerTest.php b/tests/src/Functional/Installer/ThunderInstallerTest.php index ac86df95e..cbb34bf1d 100644 --- a/tests/src/Functional/Installer/ThunderInstallerTest.php +++ b/tests/src/Functional/Installer/ThunderInstallerTest.php @@ -17,7 +17,7 @@ class ThunderInstallerTest extends InstallerTestBase { * * @var int */ - protected $knownWarnings = 0; + protected int $knownWarnings = 0; /** * {@inheritdoc} diff --git a/tests/src/Functional/Integration/ContentTranslationTest.php b/tests/src/Functional/Integration/ContentTranslationTest.php index 27bb3982c..ac81f6688 100644 --- a/tests/src/Functional/Integration/ContentTranslationTest.php +++ b/tests/src/Functional/Integration/ContentTranslationTest.php @@ -27,7 +27,7 @@ class ContentTranslationTest extends ThunderTestBase { * * @var \Drupal\language\ConfigurableLanguageInterface[] */ - protected $languages = []; + protected array|ConfigurableLanguage $languages = []; /** * {@inheritdoc} diff --git a/tests/src/Functional/ModuleUninstallTest.php b/tests/src/Functional/ModuleUninstallTest.php index 0f47cc9b4..e322ad946 100644 --- a/tests/src/Functional/ModuleUninstallTest.php +++ b/tests/src/Functional/ModuleUninstallTest.php @@ -16,7 +16,7 @@ class ModuleUninstallTest extends ThunderTestBase { * * @var string[][] */ - protected static $moduleLists = [ + protected static array $moduleLists = [ ['diff'], ['content_lock'], ['access_unpublished'], diff --git a/tests/src/FunctionalJavascript/ChannelsTagsTest.php b/tests/src/FunctionalJavascript/ChannelsTagsTest.php index fa1ed22f4..218a89966 100644 --- a/tests/src/FunctionalJavascript/ChannelsTagsTest.php +++ b/tests/src/FunctionalJavascript/ChannelsTagsTest.php @@ -19,7 +19,7 @@ class ChannelsTagsTest extends ThunderJavascriptTestBase { * * @var string */ - protected static $defaultUserRole = 'administrator'; + protected static string $defaultUserRole = 'administrator'; /** * Test channel creation, tagging of articles and channel page with articles. diff --git a/tests/src/FunctionalJavascript/Integration/DiffTest.php b/tests/src/FunctionalJavascript/Integration/DiffTest.php index 224ca1301..5fb1d8b9c 100644 --- a/tests/src/FunctionalJavascript/Integration/DiffTest.php +++ b/tests/src/FunctionalJavascript/Integration/DiffTest.php @@ -19,14 +19,14 @@ class DiffTest extends ThunderJavascriptTestBase { * * @var int */ - protected static $previousTextColumn = 3; + protected static int $previousTextColumn = 3; /** * Column in diff table used for new text. * * @var int */ - protected static $newTextColumn = 6; + protected static int $newTextColumn = 6; /** * Validate diff entry for one field. diff --git a/tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php b/tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php index d69efb405..0eb7c0ec9 100644 --- a/tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php +++ b/tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php @@ -21,7 +21,7 @@ class ParagraphSplitTest extends ThunderJavascriptTestBase { * * @var string */ - protected static $paragraphsField = 'field_paragraphs'; + protected static string $paragraphsField = 'field_paragraphs'; /** * Selector template for CKEditor instances. @@ -31,7 +31,7 @@ class ParagraphSplitTest extends ThunderJavascriptTestBase { * * @var string */ - protected static $selectorTemplate = "textarea[name='%s[%d][subform][field_text][0][value]']"; + protected static string $selectorTemplate = "textarea[name='%s[%d][subform][field_text][0][value]']"; /** * Test split of paragraph before a selection. diff --git a/tests/src/FunctionalJavascript/Integration/ParagraphsPasteTest.php b/tests/src/FunctionalJavascript/Integration/ParagraphsPasteTest.php index ad5350eeb..4c782f3d8 100644 --- a/tests/src/FunctionalJavascript/Integration/ParagraphsPasteTest.php +++ b/tests/src/FunctionalJavascript/Integration/ParagraphsPasteTest.php @@ -40,7 +40,7 @@ class ParagraphsPasteTest extends ThunderJavascriptTestBase { * * @var string */ - protected static $paragraphsField = 'field_paragraphs'; + protected static string $paragraphsField = 'field_paragraphs'; /** * Test paste functionality. diff --git a/tests/src/FunctionalJavascript/MetaInformationTest.php b/tests/src/FunctionalJavascript/MetaInformationTest.php index 43bb678ee..2009e19ac 100644 --- a/tests/src/FunctionalJavascript/MetaInformationTest.php +++ b/tests/src/FunctionalJavascript/MetaInformationTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\thunder\FunctionalJavascript; +use Drupal\simple_sitemap\Manager\Generator; use Drupal\simple_sitemap\Queue\QueueWorker; use Drupal\Tests\Traits\Core\CronRunTrait; @@ -25,14 +26,14 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var string */ - protected static $defaultUserRole = 'administrator'; + protected static string $defaultUserRole = 'administrator'; /** * Meta tag configuration that will be set for Global meta tags. * * @var array */ - protected static $globalMetaTags = [ + protected static array $globalMetaTags = [ 'basic title' => 'Global Title', 'basic keywords' => 'Thunder,CMS,Burda', 'basic abstract' => '[random]', @@ -44,7 +45,7 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var array */ - protected static $contentMetaTags = [ + protected static array $contentMetaTags = [ 'basic title' => '[node:title]', 'basic abstract' => '[random]', ]; @@ -54,7 +55,7 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var array */ - protected static $articleMetaTags = [ + protected static array $articleMetaTags = [ 'basic title' => 'Test [node:field_teaser_text]', 'basic description' => '[random]', 'advanced robots' => 'index, follow', @@ -85,7 +86,7 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var array */ - protected static $customMetaTags = [ + protected static array $customMetaTags = [ 'basic title' => 'Custom [node:field_teaser_text]', 'basic description' => '[random]', 'advanced robots' => 'follow', @@ -98,7 +99,7 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var array */ - protected static $tokens = [ + protected static array $tokens = [ '[node:field_seo_title]' => 'Test SEO Title', '[node:field_teaser_text]' => 'Test Teaser Text', '[node:title]' => 'Test Note Title', @@ -115,7 +116,7 @@ class MetaInformationTest extends ThunderJavascriptTestBase { * * @var \Drupal\simple_sitemap\Manager\Generator */ - protected $sitemapGenerator; + protected Generator $sitemapGenerator; /** * {@inheritdoc} diff --git a/tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php b/tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php index 4bf1e5dd1..0f11d48c0 100644 --- a/tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php +++ b/tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php @@ -54,14 +54,14 @@ abstract class ThunderJavascriptTestBase extends WebDriverTestBase { * * @var string */ - protected $screenshotDirectory = '/tmp/thunder-screenshots'; + protected string $screenshotDirectory = '/tmp/thunder-screenshots'; /** * Default user login role used for testing. * * @var string */ - protected static $defaultUserRole = 'editor'; + protected static string $defaultUserRole = 'editor'; /** * {@inheritdoc} diff --git a/tests/src/Kernel/MetatagTest.php b/tests/src/Kernel/MetatagTest.php index 23b76d3bb..b2251a2fb 100644 --- a/tests/src/Kernel/MetatagTest.php +++ b/tests/src/Kernel/MetatagTest.php @@ -4,6 +4,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\Node; +use Drupal\node\NodeInterface; use Drupal\Tests\thunder\Traits\ThunderKernelTestTrait; /** @@ -20,7 +21,7 @@ class MetatagTest extends KernelTestBase { * * @var \Drupal\node\NodeInterface */ - protected $node; + protected NodeInterface $node; /** * {@inheritdoc}