diff --git a/src/EventListener/BackendView/AbstractViewListener.php b/src/EventListener/BackendView/AbstractViewListener.php
index 27b2126..4384c6f 100644
--- a/src/EventListener/BackendView/AbstractViewListener.php
+++ b/src/EventListener/BackendView/AbstractViewListener.php
@@ -151,15 +151,15 @@ private function getSwitchButton(PageModel $page, array $languages): string
HTML;
foreach ($languages as $id => $language) {
- $list .= sprintf(
+ $list .= \sprintf(
'
%s',
Backend::addToUrl('&switchLanguage='.$id),
- sprintf($GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][1], $language),
+ \sprintf($GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][1], $language),
$language,
);
}
- return sprintf(
+ return \sprintf(
$markup,
$GLOBALS['TL_LANG']['MSC']['switchLanguage'],
$this->getLanguageLabel($page->language),
diff --git a/src/EventListener/DataContainer/AbstractChildTableListener.php b/src/EventListener/DataContainer/AbstractChildTableListener.php
index 58e5688..e42b947 100644
--- a/src/EventListener/DataContainer/AbstractChildTableListener.php
+++ b/src/EventListener/DataContainer/AbstractChildTableListener.php
@@ -34,7 +34,7 @@ public function onLoad(DataContainer $dc): void
}
/**
- * @return array
+ * @return array>
*/
public function onLanguageMainOptions(DataContainer $dc): array
{
@@ -54,7 +54,7 @@ public function onLanguageMainOptions(DataContainer $dc): array
$models = $class::findBy(
[
$this->table.'.pid=?',
- sprintf('%s.id NOT IN (SELECT languageMain FROM %s WHERE pid=? AND id!=?)', $this->table, $this->table),
+ \sprintf('%s.id NOT IN (SELECT languageMain FROM %s WHERE pid=? AND id!=?)', $this->table, $this->table),
],
[$master->id, $current->pid, $current->id],
);
@@ -106,7 +106,7 @@ abstract protected function getSorting();
/**
* @param Collection $models
*
- * @return array
+ * @return array>|array
*/
abstract protected function formatOptions(Model $current, Collection $models): array;
}
diff --git a/src/EventListener/DataContainer/ArticleListener.php b/src/EventListener/DataContainer/ArticleListener.php
index 4d03c08..e97f4bd 100644
--- a/src/EventListener/DataContainer/ArticleListener.php
+++ b/src/EventListener/DataContainer/ArticleListener.php
@@ -71,7 +71,7 @@ public function onLanguageMainOptions(DataContainer $dc): array
;
while ($result->next()) {
- $options[$result->id] = sprintf('%s [ID %s]', $result->title, $result->id);
+ $options[$result->id] = \sprintf('%s [ID %s]', $result->title, $result->id);
}
return $options;
diff --git a/src/EventListener/DataContainer/CalendarEventsListener.php b/src/EventListener/DataContainer/CalendarEventsListener.php
index 73ddb4a..8b4c647 100644
--- a/src/EventListener/DataContainer/CalendarEventsListener.php
+++ b/src/EventListener/DataContainer/CalendarEventsListener.php
@@ -28,7 +28,7 @@ protected function formatOptions(Model $current, Collection $models): array
$options = [];
foreach ($models as $model) {
- $options[$model->id] = sprintf(
+ $options[$model->id] = \sprintf(
'%s [%s]',
$model->title,
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->startTime),
diff --git a/src/EventListener/DataContainer/FaqListener.php b/src/EventListener/DataContainer/FaqListener.php
index 1abbc54..a5437c2 100644
--- a/src/EventListener/DataContainer/FaqListener.php
+++ b/src/EventListener/DataContainer/FaqListener.php
@@ -30,7 +30,7 @@ protected function formatOptions(Model $current, Collection $models): array
$options = [];
foreach ($models as $model) {
- $options[$model->id] = sprintf('%s [ID %s]', $model->question, $model->id);
+ $options[$model->id] = \sprintf('%s [ID %s]', $model->question, $model->id);
}
return $options;
diff --git a/src/EventListener/DataContainer/MissingLanguageIconListener.php b/src/EventListener/DataContainer/MissingLanguageIconListener.php
index 8a7ff02..611881a 100644
--- a/src/EventListener/DataContainer/MissingLanguageIconListener.php
+++ b/src/EventListener/DataContainer/MissingLanguageIconListener.php
@@ -33,7 +33,7 @@ class MissingLanguageIconListener implements ResetInterface
private Connection $connection;
/**
- * @var array|null
+ * @var array>|null
*/
private ?array $pageCache = null;
@@ -72,8 +72,8 @@ public function reset(): void
/**
* Adds missing translation warning to page tree.
*
- * @param array $args
- * @param string|array|null $previousResult;
+ * @param array{0: array, 1: string} $args
+ * @param mixed $previousResult
*/
private function onPageLabel(array $args, $previousResult = null): string
{
@@ -103,7 +103,7 @@ private function onPageLabel(array $args, $previousResult = null): string
&& \is_array($user->pageLanguageLabels)
&& \in_array($translation['rootId'] ?? null, $user->pageLanguageLabels, false)
) {
- return sprintf(
+ return \sprintf(
'%s (%s)',
$label,
Backend::addToUrl('pn='.$translation['languageMain']),
@@ -118,8 +118,8 @@ private function onPageLabel(array $args, $previousResult = null): string
/**
* Adds missing translation warning to article tree.
*
- * @param array $args
- * @param string|array|null $previousResult
+ * @param array{0: array, 1: string} $args
+ * @param mixed $previousResult
*/
private function onArticleLabel(array $args, $previousResult = null): string
{
@@ -143,8 +143,8 @@ private function onArticleLabel(array $args, $previousResult = null): string
/**
* Generate missing translation warning for news child records.
*
- * @param array $args
- * @param string|array|null $previousResult
+ * @param array{0: array} $args
+ * @param mixed $previousResult
*/
private function onNewsChildRecords(array $args, $previousResult = null): string
{
@@ -170,8 +170,8 @@ private function onNewsChildRecords(array $args, $previousResult = null): string
/**
* Generate missing translation warning for calendar events child records.
*
- * @param array $args
- * @param string|array|null $previousResult
+ * @param array{0: array} $args
+ * @param mixed $previousResult
*/
private function onCalendarEventChildRecords(array $args, $previousResult = null): string
{
@@ -193,8 +193,8 @@ private function onCalendarEventChildRecords(array $args, $previousResult = null
/**
* Generate missing translation warning for faq child records.
*
- * @param array $args
- * @param string|array|null $previousResult
+ * @param array{0: array} $args
+ * @param mixed $previousResult
*/
private function onFaqChildRecords(array $args, $previousResult = null): string
{
@@ -215,7 +215,7 @@ private function onFaqChildRecords(array $args, $previousResult = null): string
private function generateLabelWithWarning(string $label, string $imgStyle = ''): string
{
- return $label.sprintf(
+ return $label.\sprintf(
'',
'bundles/terminal42changelanguage/language-warning.png',
$GLOBALS['TL_LANG']['MSC']['noMainLanguage'],
diff --git a/src/EventListener/DataContainer/NewsListener.php b/src/EventListener/DataContainer/NewsListener.php
index fc07860..16aba65 100644
--- a/src/EventListener/DataContainer/NewsListener.php
+++ b/src/EventListener/DataContainer/NewsListener.php
@@ -36,7 +36,7 @@ protected function formatOptions(Model $current, Collection $models): array
foreach ($models as $model) {
$group = strtotime('0:00', (int) $model->date) === $dayBegin ? $sameDay : $otherDay;
- $options[$group][$model->id] = sprintf(
+ $options[$group][$model->id] = \sprintf(
'%s [%s]',
$model->headline,
Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->time),
diff --git a/src/EventListener/DataContainer/PageFieldsListener.php b/src/EventListener/DataContainer/PageFieldsListener.php
index 465ceca..355eb3e 100644
--- a/src/EventListener/DataContainer/PageFieldsListener.php
+++ b/src/EventListener/DataContainer/PageFieldsListener.php
@@ -82,10 +82,10 @@ public function onSaveLanguageMain($value, DataContainer $dc)
$labels = [];
foreach ($duplicates as $duplicate) {
- $labels[] = sprintf('%s (ID %s)', $duplicate->id, $duplicate->title);
+ $labels[] = \sprintf('%s (ID %s)', $duplicate->id, $duplicate->title);
}
- throw new \RuntimeException(sprintf($GLOBALS['TL_LANG']['MSC']['duplicateMainLanguage'], implode(', ', $labels)));
+ throw new \RuntimeException(\sprintf($GLOBALS['TL_LANG']['MSC']['duplicateMainLanguage'], implode(', ', $labels)));
}
}
@@ -120,7 +120,7 @@ public function onLanguageRootOptions(DataContainer $dc): array
$options = [];
foreach ($pages as $page) {
- $options[$page->id] = sprintf(
+ $options[$page->id] = \sprintf(
'%s%s [%s]',
$page->title,
\strlen($page->dns) ? (' ('.$page->dns.')') : '',
diff --git a/src/EventListener/DataContainer/ParentTableListener.php b/src/EventListener/DataContainer/ParentTableListener.php
index 009946b..27d50e1 100644
--- a/src/EventListener/DataContainer/ParentTableListener.php
+++ b/src/EventListener/DataContainer/ParentTableListener.php
@@ -83,7 +83,7 @@ public function onMasterOptions(DataContainer $dc): array
;
while ($result->next()) {
- $options[$result->id] = sprintf($GLOBALS['TL_LANG'][$this->table]['isSlave'], $result->title);
+ $options[$result->id] = \sprintf($GLOBALS['TL_LANG'][$this->table]['isSlave'], $result->title);
}
return $options;
@@ -109,7 +109,7 @@ private function validateMaster($value, DataContainer $dc): void
;
if ($result->numRows > 0) {
- throw new \RuntimeException(sprintf($GLOBALS['TL_LANG'][$this->table]['master'][2], $result->title));
+ throw new \RuntimeException(\sprintf($GLOBALS['TL_LANG'][$this->table]['master'][2], $result->title));
}
}
}
diff --git a/src/EventListener/InsertTagsListener.php b/src/EventListener/InsertTagsListener.php
index e0ce29a..a280664 100644
--- a/src/EventListener/InsertTagsListener.php
+++ b/src/EventListener/InsertTagsListener.php
@@ -50,7 +50,7 @@ public function __invoke(string $insertTag)
}
return $this->parser->replace(
- sprintf(
+ \sprintf(
'{{%s::%s}}',
substr($parts[0], 15),
$targetPage->id,
diff --git a/src/EventListener/Navigation/AbstractNavigationListener.php b/src/EventListener/Navigation/AbstractNavigationListener.php
index f9211d6..08cc43e 100644
--- a/src/EventListener/Navigation/AbstractNavigationListener.php
+++ b/src/EventListener/Navigation/AbstractNavigationListener.php
@@ -79,7 +79,7 @@ public function onChangelanguageNavigation(ChangelanguageNavigationEvent $event)
$translated = $this->findPublishedBy(
[
"($t.id=? OR $t.languageMain=?)",
- sprintf('%s.pid=(SELECT id FROM %s WHERE (id=? OR master=?) AND jumpTo=?)', $t, $parent::getTable()),
+ \sprintf('%s.pid=(SELECT id FROM %s WHERE (id=? OR master=?) AND jumpTo=?)', $t, $parent::getTable()),
],
[$mainId, $mainId, $masterId, $masterId, $targetPage->id],
);
@@ -148,8 +148,8 @@ abstract protected function getUrlKey();
abstract protected function findCurrent();
/**
- * @param array $columns
- * @param array $values
+ * @param array $columns
+ * @param array $values
* @param array $options
*
* @return Model|null
diff --git a/src/EventListener/Navigation/CalendarNavigationListener.php b/src/EventListener/Navigation/CalendarNavigationListener.php
index 6d9f58f..072bc34 100644
--- a/src/EventListener/Navigation/CalendarNavigationListener.php
+++ b/src/EventListener/Navigation/CalendarNavigationListener.php
@@ -52,8 +52,8 @@ protected function findCurrent(): ?CalendarEventsModel
}
/**
- * @param array $columns
- * @param array $values
+ * @param array $columns
+ * @param array $values
* @param array $options
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = [])
diff --git a/src/EventListener/Navigation/FaqNavigationListener.php b/src/EventListener/Navigation/FaqNavigationListener.php
index a084875..dbabcb5 100644
--- a/src/EventListener/Navigation/FaqNavigationListener.php
+++ b/src/EventListener/Navigation/FaqNavigationListener.php
@@ -52,8 +52,8 @@ protected function findCurrent(): ?FaqModel
}
/**
- * @param array $columns
- * @param array $values
+ * @param array $columns
+ * @param array $values
* @param array $options
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = []): ?FaqModel
diff --git a/src/EventListener/Navigation/NewsNavigationListener.php b/src/EventListener/Navigation/NewsNavigationListener.php
index 42d8840..8fb01b0 100644
--- a/src/EventListener/Navigation/NewsNavigationListener.php
+++ b/src/EventListener/Navigation/NewsNavigationListener.php
@@ -55,10 +55,9 @@ protected function findCurrent(): ?NewsModel
}
/**
- * @param array $columns
- * @param array $values
+ * @param array $columns
+ * @param array $values
* @param array $options
- * @return NewsModel|null
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = []): ?NewsModel
{
diff --git a/src/FrontendModule/ChangeLanguageModule.php b/src/FrontendModule/ChangeLanguageModule.php
index e9fcd6e..d566aec 100755
--- a/src/FrontendModule/ChangeLanguageModule.php
+++ b/src/FrontendModule/ChangeLanguageModule.php
@@ -167,6 +167,9 @@ protected function generateTemplateArray(NavigationItem $item, UrlParameterBag $
];
}
+ /**
+ * @param array> $items
+ */
protected function generateNavigationTemplate(array $items): string
{
$objTemplate = new FrontendTemplate($this->navigationTpl ?: 'nav_default');
@@ -188,7 +191,7 @@ protected function getCurrentPage(): PageModel
/**
* Creates an UrlParameterBag from the current environment.
*
- * @param array $queryParameters An array of query parameters to keep
+ * @param array $queryParameters An array of query parameters to keep
*/
protected function createUrlParameterBag(array $queryParameters = []): UrlParameterBag
{
diff --git a/src/Helper/LabelCallback.php b/src/Helper/LabelCallback.php
index 904b853..10e2365 100644
--- a/src/Helper/LabelCallback.php
+++ b/src/Helper/LabelCallback.php
@@ -53,8 +53,8 @@ public static function createAndRegister(string $table, callable $callback): sel
}
/**
- * @param callable|array $callback
- * @param array $args
+ * @param callable|array $callback
+ * @param array $args
*
* @return mixed
*/
diff --git a/src/Language.php b/src/Language.php
index d3c1245..9ffab7c 100644
--- a/src/Language.php
+++ b/src/Language.php
@@ -15,7 +15,7 @@ class Language
public static function normalize(string $language, string $delimiter): string
{
if (!preg_match('#^([a-z]{2})((-|_)([A-Z]{2}))?$#i', $language, $matches)) {
- throw new \InvalidArgumentException(sprintf('"%s" is not a supported language format.', $language));
+ throw new \InvalidArgumentException(\sprintf('"%s" is not a supported language format.', $language));
}
return strtolower($matches[1]).(isset($matches[4]) ? $delimiter.strtoupper($matches[4]) : '');
diff --git a/src/Navigation/NavigationFactory.php b/src/Navigation/NavigationFactory.php
index 70c9756..98d014a 100644
--- a/src/Navigation/NavigationFactory.php
+++ b/src/Navigation/NavigationFactory.php
@@ -53,8 +53,8 @@ public function findNavigationItems(PageModel $currentPage): array
if (isset($this->locales[$item->getLocaleId()])) {
$item->setAriaLabel(
$item->isDirectFallback()
- ? sprintf($GLOBALS['TL_LANG']['MSC']['gotoLanguage'], $this->locales[$item->getLocaleId()])
- : sprintf($GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][1], $this->locales[$item->getLocaleId()]),
+ ? \sprintf($GLOBALS['TL_LANG']['MSC']['gotoLanguage'], $this->locales[$item->getLocaleId()])
+ : \sprintf($GLOBALS['TL_LANG']['MSC']['switchLanguageTo'][1], $this->locales[$item->getLocaleId()]),
);
}
@@ -98,7 +98,7 @@ private function createNavigationItemsForRootPages(array $rootPages): array
$language = strtolower($rootPage->language);
if (\array_key_exists($language, $navigationItems)) {
- throw new \RuntimeException(sprintf('Multiple root pages for the language "%s" found', $rootPage->language));
+ throw new \RuntimeException(\sprintf('Multiple root pages for the language "%s" found', $rootPage->language));
}
$navigationItems[$language] = new NavigationItem($rootPage, $this->languageText->get($language));
@@ -122,7 +122,7 @@ private function setTargetPageForNavigationItems(array $navigationItems, array $
$page->loadDetails();
if (!\array_key_exists($page->rootId, $rootPages)) {
- throw new \RuntimeException(sprintf('Missing root page for language "%s"', $page->language));
+ throw new \RuntimeException(\sprintf('Missing root page for language "%s"', $page->language));
}
if (!$this->isPagePublished($rootPages[$page->rootId])) {
diff --git a/src/Navigation/NavigationItem.php b/src/Navigation/NavigationItem.php
index c017fea..154fd84 100644
--- a/src/Navigation/NavigationItem.php
+++ b/src/Navigation/NavigationItem.php
@@ -33,7 +33,7 @@ class NavigationItem
public function __construct(PageModel $rootPage, ?string $label = null)
{
if ('root' !== $rootPage->type) {
- throw new \RuntimeException(sprintf('Page ID "%s" has type "%s" but should be "root"', $rootPage->id, $rootPage->type));
+ throw new \RuntimeException(\sprintf('Page ID "%s" has type "%s" but should be "root"', $rootPage->id, $rootPage->type));
}
$this->rootPage = $rootPage->loadDetails();
diff --git a/src/Navigation/UrlParameterBag.php b/src/Navigation/UrlParameterBag.php
index df8cf1e..baf0674 100644
--- a/src/Navigation/UrlParameterBag.php
+++ b/src/Navigation/UrlParameterBag.php
@@ -7,15 +7,18 @@
class UrlParameterBag
{
/**
- * @var array
+ * @var array
*/
private array $attributes;
+ /**
+ * @var array>
+ */
private array $query;
/**
- * @param array $attributes Route parameters (e.g. items=foobar in /alias/items/foobar.html)
- * @param array $query The URL query parameters
+ * @param array $attributes Route parameters (e.g. items=foobar in /alias/items/foobar.html)
+ * @param array> $query The URL query parameters
*/
public function __construct(array $attributes = [], array $query = [])
{
@@ -72,11 +75,17 @@ public function removeUrlAttribute(string $name): void
unset($this->attributes[$name]);
}
+ /**
+ * @return array>
+ */
public function getQueryParameters(): array
{
return $this->query;
}
+ /**
+ * @param array> $query
+ */
public function setQueryParameters(array $query): void
{
$this->validateScalar($query);
diff --git a/src/PageFinder.php b/src/PageFinder.php
index 2b2d893..84e6515 100644
--- a/src/PageFinder.php
+++ b/src/PageFinder.php
@@ -188,13 +188,13 @@ public function findAssociatedParentForLanguage(PageModel $page, string $languag
}
}
- throw new \InvalidArgumentException(sprintf('There\'s no language "%s" related to root page ID "%s"', $language, $page->id));
+ throw new \InvalidArgumentException(\sprintf('There\'s no language "%s" related to root page ID "%s"', $language, $page->id));
}
$parent = PageModel::findPublishedById($page->pid);
if (!$parent instanceof PageModel) {
- throw new \RuntimeException(sprintf('Parent page for page ID "%s" not found', $page->id));
+ throw new \RuntimeException(\sprintf('Parent page for page ID "%s" not found', $page->id));
}
return $this->findAssociatedForLanguage($parent, $language);
@@ -216,8 +216,8 @@ private function addPublishingConditions(array &$columns, string $table): void
}
/**
- * @param array $columns
- * @param array $values
+ * @param array $columns
+ * @param array $values
* @param array $options
*
* @return array
diff --git a/tests/LanguageTest.php b/tests/LanguageTest.php
index 47cdcd4..db60aa8 100644
--- a/tests/LanguageTest.php
+++ b/tests/LanguageTest.php
@@ -36,7 +36,7 @@ public function testInvalidLanguage(string $language): void
}
/**
- * @return iterable
+ * @return iterable>
*/
public static function languagesProvider(): iterable
{
@@ -48,7 +48,7 @@ public static function languagesProvider(): iterable
}
/**
- * @return iterable
+ * @return iterable>
*/
public static function invalidLanguagesProvider(): iterable
{
diff --git a/tests/Navigation/UrlParameterBagTest.php b/tests/Navigation/UrlParameterBagTest.php
index 4956a75..86c6925 100644
--- a/tests/Navigation/UrlParameterBagTest.php
+++ b/tests/Navigation/UrlParameterBagTest.php
@@ -117,6 +117,7 @@ public function testExceptionOnConstructNonScalarParameter(): void
{
$this->expectException('InvalidArgumentException');
+ /** @phpstan-ignore argument.type */
new UrlParameterBag(['foo' => (object) ['bar']]);
}
@@ -126,6 +127,7 @@ public function testExceptionOnSettingNonScalarParameter(): void
$bag = new UrlParameterBag();
+ /** @phpstan-ignore argument.type */
$bag->setUrlAttribute('foo', (object) ['bar']);
}
@@ -135,6 +137,7 @@ public function testExceptionOnSettingNonScalarParameters(): void
$bag = new UrlParameterBag();
+ /** @phpstan-ignore argument.type */
$bag->setUrlAttributes(['foo' => (object) ['bar']]);
}
@@ -170,6 +173,7 @@ public function testExceptionOnConstructNonScalarQuery(): void
{
$this->expectException('InvalidArgumentException');
+ /** @phpstan-ignore argument.type */
new UrlParameterBag([], ['foo' => (object) ['bar']]);
}
@@ -179,6 +183,7 @@ public function testExceptionOnSettingNonScalarQuery(): void
$bag = new UrlParameterBag();
+ /** @phpstan-ignore argument.type */
$bag->setQueryParameter('foo', (object) ['bar']);
}
@@ -188,6 +193,7 @@ public function testExceptionOnSettingNonScalarQuerys(): void
$bag = new UrlParameterBag();
+ /** @phpstan-ignore argument.type */
$bag->setQueryParameters(['foo' => (object) ['bar']]);
}
}