From 269ae23c72d6a8137cb34a56a9c9e81f71028660 Mon Sep 17 00:00:00 2001 From: Marc Reimann Date: Wed, 4 Mar 2026 14:48:06 +0100 Subject: [PATCH 1/2] Add key fingerprint for psalm --- src/Attribute/BaseSimple.php | 4 +-- src/Attribute/TranslatedReference.php | 2 +- ...bstractContentElementAndModuleCallback.php | 4 +-- .../Backend/AbstractAddAllController.php | 2 +- .../Backend/ConfigurationController.php | 2 +- .../Backend/MetaModelController.php | 2 +- .../Backend/SupportMetaModelsController.php | 2 +- .../ContentElement/ItemListController.php | 4 +-- .../FrontendModule/ItemListController.php | 4 +-- .../Controller/ListControllerTrait.php | 6 ++--- .../DependencyInjection/Configuration.php | 4 +-- .../DefinitionBuilder/PaletteBuilder.php | 4 +-- .../Table/Attribute/BaseListener.php | 2 +- .../GetSearchablePagesListener.php | 2 +- .../EventListener/InsertTagsListener.php | 2 +- src/Filter/FilterUrlBuilder.php | 4 +-- src/Filter/Setting/Simple.php | 6 ++--- src/Filter/Setting/SimpleLookup.php | 2 -- src/FrontendIntegration/FrontendFilter.php | 12 ++++----- src/Helper/ToolboxFile.php | 10 ++++---- src/Item.php | 2 +- src/ItemList.php | 25 +++++++++---------- src/MetaModel.php | 4 +-- src/Render/Setting/Collection.php | 4 +-- src/Render/Template.php | 6 ++--- 25 files changed, 59 insertions(+), 62 deletions(-) diff --git a/src/Attribute/BaseSimple.php b/src/Attribute/BaseSimple.php index 10c5c1947..13a907f2f 100644 --- a/src/Attribute/BaseSimple.php +++ b/src/Attribute/BaseSimple.php @@ -78,8 +78,8 @@ class BaseSimple extends Base implements ISimple public function __construct( IMetaModel $objMetaModel, $arrData = [], - Connection $connection = null, - TableManipulator $tableManipulator = null + ?Connection $connection = null, + ?TableManipulator $tableManipulator = null ) { parent::__construct($objMetaModel, $arrData); diff --git a/src/Attribute/TranslatedReference.php b/src/Attribute/TranslatedReference.php index f7cea603e..f27884a36 100644 --- a/src/Attribute/TranslatedReference.php +++ b/src/Attribute/TranslatedReference.php @@ -58,7 +58,7 @@ abstract class TranslatedReference extends BaseComplex implements ITranslated * classes for information what values are understood. * @param Connection|null $connection Database connection. */ - public function __construct(IMetaModel $objMetaModel, $arrData = [], Connection $connection = null) + public function __construct(IMetaModel $objMetaModel, $arrData = [], ?Connection $connection = null) { parent::__construct($objMetaModel, $arrData); diff --git a/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php b/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php index 1e4354449..a67525940 100644 --- a/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php +++ b/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php @@ -370,7 +370,7 @@ protected function buildFilterParamsFor(DC_Table $dataContainer, $elementName) * * @return string|null */ - public function saveCallback(string $value = null) + public function saveCallback(?string $value = null) { return ('--null--' === $value || null === $value) ? null : base64_decode($value); } @@ -382,7 +382,7 @@ public function saveCallback(string $value = null) * * @return string|null */ - public function loadCallback(string $value = null) + public function loadCallback(?string $value = null) { return null === $value ? '--null--' : trim(base64_encode($value), '='); } diff --git a/src/CoreBundle/Controller/Backend/AbstractAddAllController.php b/src/CoreBundle/Controller/Backend/AbstractAddAllController.php index 1c89b607f..50ce7b230 100644 --- a/src/CoreBundle/Controller/Backend/AbstractAddAllController.php +++ b/src/CoreBundle/Controller/Backend/AbstractAddAllController.php @@ -22,7 +22,7 @@ namespace MetaModels\CoreBundle\Controller\Backend; -use Contao\CoreBundle\Controller\AbstractBackendController; +use Contao\CoreBundle\Controller\Backend\AbstractBackendController; use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager; use Contao\CoreBundle\Framework\Adapter; use Contao\System; diff --git a/src/CoreBundle/Controller/Backend/ConfigurationController.php b/src/CoreBundle/Controller/Backend/ConfigurationController.php index fd73768dc..da2417fa5 100644 --- a/src/CoreBundle/Controller/Backend/ConfigurationController.php +++ b/src/CoreBundle/Controller/Backend/ConfigurationController.php @@ -20,7 +20,7 @@ namespace MetaModels\CoreBundle\Controller\Backend; -use Contao\CoreBundle\Controller\AbstractBackendController; +use Contao\CoreBundle\Controller\Backend\AbstractBackendController; use Contao\CoreBundle\Framework\ContaoFramework; use ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactoryService; use ContaoCommunityAlliance\Translator\TranslatorInterface; diff --git a/src/CoreBundle/Controller/Backend/MetaModelController.php b/src/CoreBundle/Controller/Backend/MetaModelController.php index e86fa808e..04e51b9ed 100644 --- a/src/CoreBundle/Controller/Backend/MetaModelController.php +++ b/src/CoreBundle/Controller/Backend/MetaModelController.php @@ -20,7 +20,7 @@ namespace MetaModels\CoreBundle\Controller\Backend; -use Contao\CoreBundle\Controller\AbstractBackendController; +use Contao\CoreBundle\Controller\Backend\AbstractBackendController; use Contao\CoreBundle\Exception\AccessDeniedException; use Contao\CoreBundle\Framework\ContaoFramework; use Contao\CoreBundle\Menu\BackendMenuBuilder; diff --git a/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php b/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php index 1bd10c45d..2af470b31 100644 --- a/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php +++ b/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php @@ -22,7 +22,7 @@ namespace MetaModels\CoreBundle\Controller\Backend; -use Contao\CoreBundle\Controller\AbstractBackendController; +use Contao\CoreBundle\Controller\Backend\AbstractBackendController; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; use Twig\Environment as TwigEnvironment; diff --git a/src/CoreBundle/Controller/ContentElement/ItemListController.php b/src/CoreBundle/Controller/ContentElement/ItemListController.php index e1f25becd..0f40ee7e4 100644 --- a/src/CoreBundle/Controller/ContentElement/ItemListController.php +++ b/src/CoreBundle/Controller/ContentElement/ItemListController.php @@ -59,8 +59,8 @@ public function __invoke( Request $request, ContentModel $model, string $section, - array $classes = null, - PageModel $pageModel = null + ?array $classes = null, + ?PageModel $pageModel = null ): Response { if ($this->scopeMatcher->isBackendRequest($request)) { return $this->getBackendWildcard($model); diff --git a/src/CoreBundle/Controller/FrontendModule/ItemListController.php b/src/CoreBundle/Controller/FrontendModule/ItemListController.php index 9754b2f25..51dedaba0 100644 --- a/src/CoreBundle/Controller/FrontendModule/ItemListController.php +++ b/src/CoreBundle/Controller/FrontendModule/ItemListController.php @@ -58,8 +58,8 @@ public function __invoke( Request $request, ModuleModel $model, string $section, - array $classes = null, - PageModel $pageModel = null + ?array $classes = null, + ?PageModel $pageModel = null ): Response { if ($this->scopeMatcher->isBackendRequest($request)) { return $this->getBackendWildcard($model); diff --git a/src/CoreBundle/Controller/ListControllerTrait.php b/src/CoreBundle/Controller/ListControllerTrait.php index 6aff60ad2..a52c5aa1c 100644 --- a/src/CoreBundle/Controller/ListControllerTrait.php +++ b/src/CoreBundle/Controller/ListControllerTrait.php @@ -124,9 +124,9 @@ public function __construct( IRenderSettingFactory $renderSettingFactory, EventDispatcherInterface $eventDispatcher, FilterUrlBuilder $filterUrlBuilder, - TranslatorInterface $translator = null, - RouterInterface $router = null, - ScopeMatcher $scopeMatcher = null + ?TranslatorInterface $translator = null, + ?RouterInterface $router = null, + ?ScopeMatcher $scopeMatcher = null ) { $this->factory = $factory; $this->filterFactory = $filterFactory; diff --git a/src/CoreBundle/DependencyInjection/Configuration.php b/src/CoreBundle/DependencyInjection/Configuration.php index aa518ef4f..6f10632e4 100644 --- a/src/CoreBundle/DependencyInjection/Configuration.php +++ b/src/CoreBundle/DependencyInjection/Configuration.php @@ -51,7 +51,7 @@ class Configuration implements ConfigurationInterface * @param bool $debug The debug flag. * @param string $rootDir The root directory. */ - public function __construct($debug, $rootDir) + public function __construct(bool $debug, string $rootDir) { $this->debug = $debug; $this->rootDir = $rootDir; @@ -65,7 +65,7 @@ public function __construct($debug, $rootDir) * @psalm-suppress UndefinedMethod */ #[\Override] - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('metamodels'); $treeBuilder diff --git a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php index 1dc6317c0..a2c4d4cf3 100644 --- a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php +++ b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php @@ -173,8 +173,8 @@ private function createProperty( PropertyInterface $property, string $propertyName, bool $variantHandling, - ConditionInterface $condition = null, - ConditionInterface $legendCondition = null + ?ConditionInterface $condition = null, + ?ConditionInterface $legendCondition = null ): Property { $paletteProperty = new Property($propertyName); diff --git a/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php b/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php index 85a43ee20..081587296 100644 --- a/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php +++ b/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php @@ -107,7 +107,7 @@ protected function getMetaModelByModelPid(ModelInterface $model) * * @throws \InvalidArgumentException When the MetaModel could not be retrieved. */ - protected function createAttributeInstance(ModelInterface $model = null) + protected function createAttributeInstance(?ModelInterface $model = null) { if (null === $model) { return null; diff --git a/src/CoreBundle/EventListener/GetSearchablePagesListener.php b/src/CoreBundle/EventListener/GetSearchablePagesListener.php index a69f6d226..77a3b9223 100644 --- a/src/CoreBundle/EventListener/GetSearchablePagesListener.php +++ b/src/CoreBundle/EventListener/GetSearchablePagesListener.php @@ -352,7 +352,7 @@ private function buildUrlsForItems( * * @return UrlBuilder */ - private function getBaseUrl(array $pageDetails, string $path = null): UrlBuilder + private function getBaseUrl(array $pageDetails, ?string $path = null): UrlBuilder { $url = new UrlBuilder(); // Set the domain (see contao/core#6421) diff --git a/src/CoreBundle/EventListener/InsertTagsListener.php b/src/CoreBundle/EventListener/InsertTagsListener.php index e7c2523ba..e86e869f1 100644 --- a/src/CoreBundle/EventListener/InsertTagsListener.php +++ b/src/CoreBundle/EventListener/InsertTagsListener.php @@ -116,7 +116,7 @@ public function __construct( IFactory $factory, IRenderSettingFactory $renderSettingFactory, IFilterSettingFactory $filterSettingFactory, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->connection = $connection; $this->factory = $factory; diff --git a/src/Filter/FilterUrlBuilder.php b/src/Filter/FilterUrlBuilder.php index a43a5e189..482419fdf 100644 --- a/src/Filter/FilterUrlBuilder.php +++ b/src/Filter/FilterUrlBuilder.php @@ -128,7 +128,7 @@ public function generate(FilterUrl $filterUrl): string * * @return FilterUrl */ - public function getCurrentFilterUrl(array $options = null): FilterUrl + public function getCurrentFilterUrl(?array $options = null): FilterUrl { $this->addFromCurrentRequest($filterUrl = new FilterUrl(), $options); @@ -155,7 +155,7 @@ public function getCurrentFilterUrl(array $options = null): FilterUrl * * @return void */ - public function addFromCurrentRequest(FilterUrl $filterUrl, array $options = null): void + public function addFromCurrentRequest(FilterUrl $filterUrl, ?array $options = null): void { if (null === $options) { $options = [ diff --git a/src/Filter/Setting/Simple.php b/src/Filter/Setting/Simple.php index f4f76ee99..abdcdc24c 100644 --- a/src/Filter/Setting/Simple.php +++ b/src/Filter/Setting/Simple.php @@ -98,9 +98,9 @@ abstract class Simple implements ISimple public function __construct( $collection, $data, - EventDispatcherInterface $eventDispatcher = null, - FilterUrlBuilder $filterUrlBuilder = null, - TranslatorInterface $translator = null + ?EventDispatcherInterface $eventDispatcher = null, + ?FilterUrlBuilder $filterUrlBuilder = null, + ?TranslatorInterface $translator = null ) { $this->collection = $collection; $this->data = $data; diff --git a/src/Filter/Setting/SimpleLookup.php b/src/Filter/Setting/SimpleLookup.php index 9537a3ec5..c3c07188e 100644 --- a/src/Filter/Setting/SimpleLookup.php +++ b/src/Filter/Setting/SimpleLookup.php @@ -24,7 +24,6 @@ namespace MetaModels\Filter\Setting; use Contao\StringUtil; -use Contao\System; use MetaModels\Attribute\IAttribute; use MetaModels\FrontendIntegration\FrontendFilterOptions; use MetaModels\IItem; @@ -34,7 +33,6 @@ use MetaModels\IMetaModel; use MetaModels\ITranslatedMetaModel; use MetaModels\Render\Setting\ICollection as IRenderSettings; -use Symfony\Contracts\Translation\TranslatorInterface; /** * Filter setting implementation performing a search for a value on a configured attribute. diff --git a/src/FrontendIntegration/FrontendFilter.php b/src/FrontendIntegration/FrontendFilter.php index 7d7b43647..6006a5370 100644 --- a/src/FrontendIntegration/FrontendFilter.php +++ b/src/FrontendIntegration/FrontendFilter.php @@ -94,14 +94,14 @@ class FrontendFilter /** * FrontendFilter constructor. * - * @param Connection|null $connection Database connection. - * @param FilterUrlBuilder|null $filterUrlBuilder The filter URL builder. - * @param TranslatorInterface $translator The translator. + * @param Connection|null $connection Database connection. + * @param FilterUrlBuilder|null $filterUrlBuilder The filter URL builder. + * @param TranslatorInterface|null $translator The translator. */ public function __construct( - Connection $connection = null, - FilterUrlBuilder $filterUrlBuilder = null, - TranslatorInterface $translator = null + ?Connection $connection = null, + ?FilterUrlBuilder $filterUrlBuilder = null, + ?TranslatorInterface $translator = null ) { if (null === $connection) { // @codingStandardsIgnoreStart diff --git a/src/Helper/ToolboxFile.php b/src/Helper/ToolboxFile.php index 4820633f1..ea620af6a 100644 --- a/src/Helper/ToolboxFile.php +++ b/src/Helper/ToolboxFile.php @@ -249,11 +249,11 @@ class ToolboxFile * @SuppressWarnings(PHPMD.NPathComplexity) */ public function __construct( - ImageFactoryInterface|EventDispatcherInterface $imageFactory = null, - string $rootDir = null, - ContextInterface $filesContext = null, - PictureFactoryInterface $pictureFactory = null, - RequestStack $requestStack = null + ImageFactoryInterface|EventDispatcherInterface|null $imageFactory = null, + ?string $rootDir = null, + ?ContextInterface $filesContext = null, + ?PictureFactoryInterface $pictureFactory = null, + ?RequestStack $requestStack = null ) { switch (true) { case ($imageFactory instanceof ImageFactoryInterface) && (null !== $rootDir): diff --git a/src/Item.php b/src/Item.php index 39994e7f7..f4616b871 100644 --- a/src/Item.php +++ b/src/Item.php @@ -72,7 +72,7 @@ class Item implements IItem * @param array|null $arrData The initial data that shall be injected into the new instance. * @param EventDispatcherInterface|null $dispatcher The event dispatcher. */ - public function __construct(IMetaModel $objMetaModel, $arrData, EventDispatcherInterface $dispatcher = null) + public function __construct(IMetaModel $objMetaModel, $arrData, ?EventDispatcherInterface $dispatcher = null) { $this->metaModel = $objMetaModel; $this->dispatcher = $dispatcher; diff --git a/src/ItemList.php b/src/ItemList.php index 7f650efe7..7da392446 100644 --- a/src/ItemList.php +++ b/src/ItemList.php @@ -65,7 +65,6 @@ use function func_num_args; use function in_array; use function is_int; -use function is_object; use function sprintf; use function strtoupper; use function trigger_error; @@ -221,16 +220,16 @@ class ItemList * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - IFactory $factory = null, - IFilterSettingFactory $filterFactory = null, - IRenderSettingFactory $renderSettingFactory = null, - EventDispatcherInterface $eventDispatcher = null, - FilterUrlBuilder $filterUrlBuilder = null, - string $pageParam = 'page', - string $paramType = 'get', - int $maxPaginationLinks = 0, - string $paginationTemplate = 'mm_pagination', - string $paginationFragment = '' + ?IFactory $factory = null, + ?IFilterSettingFactory $filterFactory = null, + ?IRenderSettingFactory $renderSettingFactory = null, + ?EventDispatcherInterface $eventDispatcher = null, + ?FilterUrlBuilder $filterUrlBuilder = null, + string $pageParam = 'page', + string $paramType = 'get', + int $maxPaginationLinks = 0, + string $paginationTemplate = 'mm_pagination', + string $paginationFragment = '' ) { $this->paginationLimitCalculator = new PaginationLimitCalculator( $filterUrlBuilder, @@ -500,7 +499,7 @@ public function setSorting(string $sortBy, string $sortDirection = 'ASC'): self * * @return ItemList */ - public function overrideOutputFormat(string $outputFormat = null): self + public function overrideOutputFormat(?string $outputFormat = null): self { $outputFormat = (string) $outputFormat; if ('' !== $outputFormat) { @@ -1259,7 +1258,7 @@ public function setSortingLinkGenerator(SortingLinkGenerator $generator): self * * @psalm-suppress UndefinedMagicPropertyAssignment */ - public function render(bool $isNoNativeParsing, object $caller = null): string + public function render(bool $isNoNativeParsing, ?object $caller = null): string { if (func_num_args() > 1) { trigger_error('Passing $objCaller as second argument is deprecated', E_USER_DEPRECATED); diff --git a/src/MetaModel.php b/src/MetaModel.php index b9cbf0967..7764f368c 100644 --- a/src/MetaModel.php +++ b/src/MetaModel.php @@ -124,8 +124,8 @@ class MetaModel implements IMetaModel */ public function __construct( $arrData, - EventDispatcherInterface $dispatcher = null, - Connection $connection = null + ?EventDispatcherInterface $dispatcher = null, + ?Connection $connection = null ) { foreach ($arrData as $strKey => $varValue) { $this->arrData[$strKey] = $this->tryUnserialize($varValue); diff --git a/src/Render/Setting/Collection.php b/src/Render/Setting/Collection.php index 9f8370533..de0d2f175 100644 --- a/src/Render/Setting/Collection.php +++ b/src/Render/Setting/Collection.php @@ -108,7 +108,7 @@ public function __construct( array $arrInformation, EventDispatcherInterface $dispatcher, IFilterSettingFactory $filterFactory, - FilterUrlBuilder $filterUrlBuilder = null + ?FilterUrlBuilder $filterUrlBuilder = null ) { $this->metaModel = $metaModel; $this->dispatcher = $dispatcher; @@ -281,7 +281,7 @@ private function determineJumpToInformation(): array * * @return array */ - private function lookupJumpTo(bool $translated, string $desired = null, string $fallback = null): array + private function lookupJumpTo(bool $translated, ?string $desired = null, ?string $fallback = null): array { $jumpToPageId = ''; $filterSettingId = ''; diff --git a/src/Render/Template.php b/src/Render/Template.php index 60680cd4b..22c6f83d6 100644 --- a/src/Render/Template.php +++ b/src/Render/Template.php @@ -148,8 +148,8 @@ public function __call($strMethod, $arrArgs) */ public function __construct( $strTemplate = '', - Adapter $templateLoader = null, - RequestScopeDeterminator $scopeDeterminator = null + ?Adapter $templateLoader = null, + ?RequestScopeDeterminator $scopeDeterminator = null ) { $this->strTemplate = $strTemplate; @@ -638,7 +638,7 @@ public function endblock() * * @return void */ - public function insert($strName, array $arrData = null) + public function insert($strName, ?array $arrData = null) { if ($this->scopeDeterminator->currentScopeIsBackend()) { $objTemplate = new BackendTemplate($strName); From 3e809a69750f9f52e2f1fd1d049e00e6397af453 Mon Sep 17 00:00:00 2001 From: Marc Reimann Date: Mon, 9 Mar 2026 14:16:58 +0100 Subject: [PATCH 2/2] Fix deprecations --- src/Render/Setting/Collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Render/Setting/Collection.php b/src/Render/Setting/Collection.php index de0d2f175..d08b4b611 100644 --- a/src/Render/Setting/Collection.php +++ b/src/Render/Setting/Collection.php @@ -322,7 +322,7 @@ private function lookupJumpTo(bool $translated, ?string $desired = null, ?string * {@inheritdoc} */ #[\Override] - public function buildJumpToUrlFor(IItem $item /**, ?int $referenceType */) + public function buildJumpToUrlFor(IItem $item, ?int $referenceType = null) { $information = $this->determineJumpToInformation(); if (empty($information['pageDetails'])) {