Skip to content

Commit

Permalink
Fixed build chain
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 30, 2024
1 parent c8e0d6f commit 7cbee41
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 57 deletions.
6 changes: 3 additions & 3 deletions src/EventListener/BackendView/AbstractViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ private function getSwitchButton(PageModel $page, array $languages): string
HTML;

foreach ($languages as $id => $language) {
$list .= sprintf(
$list .= \sprintf(
'<li><a href="%s" title="%s">%s</a></li>',
Backend::addToUrl('&amp;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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function onLoad(DataContainer $dc): void
}

/**
* @return array<int|string, string>
* @return array<string, array<int|string, string>>
*/
public function onLanguageMainOptions(DataContainer $dc): array
{
Expand All @@ -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],
);
Expand Down Expand Up @@ -106,7 +106,7 @@ abstract protected function getSorting();
/**
* @param Collection<Model> $models
*
* @return array<int|string, string>
* @return array<string, array<int|string, string>>|array<int|string, string>
*/
abstract protected function formatOptions(Model $current, Collection $models): array;
}
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/ArticleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/CalendarEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/FaqListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions src/EventListener/DataContainer/MissingLanguageIconListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MissingLanguageIconListener implements ResetInterface
private Connection $connection;

/**
* @var array<int|string, array>|null
* @var array<int|string, array<int|string>>|null
*/
private ?array $pageCache = null;

Expand Down Expand Up @@ -72,8 +72,8 @@ public function reset(): void
/**
* Adds missing translation warning to page tree.
*
* @param array<string|array> $args
* @param string|array|null $previousResult;
* @param array{0: array<string, int|string>, 1: string} $args
* @param mixed $previousResult
*/
private function onPageLabel(array $args, $previousResult = null): string
{
Expand Down Expand Up @@ -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 <span style="color:#999;padding-left:3px">(<a href="%s" title="%s" style="color:#999">%s</a>)</span>',
$label,
Backend::addToUrl('pn='.$translation['languageMain']),
Expand All @@ -118,8 +118,8 @@ private function onPageLabel(array $args, $previousResult = null): string
/**
* Adds missing translation warning to article tree.
*
* @param array<int, string> $args
* @param string|array|null $previousResult
* @param array{0: array<string, int|string>, 1: string} $args
* @param mixed $previousResult
*/
private function onArticleLabel(array $args, $previousResult = null): string
{
Expand All @@ -143,8 +143,8 @@ private function onArticleLabel(array $args, $previousResult = null): string
/**
* Generate missing translation warning for news child records.
*
* @param array<int, string> $args
* @param string|array|null $previousResult
* @param array{0: array<string, int|string>} $args
* @param mixed $previousResult
*/
private function onNewsChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -170,8 +170,8 @@ private function onNewsChildRecords(array $args, $previousResult = null): string
/**
* Generate missing translation warning for calendar events child records.
*
* @param array<int, string> $args
* @param string|array|null $previousResult
* @param array{0: array<string, int|string>} $args
* @param mixed $previousResult
*/
private function onCalendarEventChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -193,8 +193,8 @@ private function onCalendarEventChildRecords(array $args, $previousResult = null
/**
* Generate missing translation warning for faq child records.
*
* @param array<int, string> $args
* @param string|array|null $previousResult
* @param array{0: array<string, int|string>} $args
* @param mixed $previousResult
*/
private function onFaqChildRecords(array $args, $previousResult = null): string
{
Expand All @@ -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(
'<span style="padding-left:3px"><img src="%s" alt="%s" title="%s" style="%s"></span>',
'bundles/terminal42changelanguage/language-warning.png',
$GLOBALS['TL_LANG']['MSC']['noMainLanguage'],
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/NewsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/DataContainer/PageFieldsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand Down Expand Up @@ -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.')') : '',
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/DataContainer/ParentTableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
}
2 changes: 1 addition & 1 deletion src/EventListener/InsertTagsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __invoke(string $insertTag)
}

return $this->parser->replace(
sprintf(
\sprintf(
'{{%s::%s}}',
substr($parts[0], 15),
$targetPage->id,
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/Navigation/AbstractNavigationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down Expand Up @@ -148,8 +148,8 @@ abstract protected function getUrlKey();
abstract protected function findCurrent();

/**
* @param array<string> $columns
* @param array<string> $values
* @param array<string> $columns
* @param array<string|int> $values
* @param array<string, string> $options
*
* @return Model|null
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Navigation/CalendarNavigationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected function findCurrent(): ?CalendarEventsModel
}

/**
* @param array<string> $columns
* @param array<string> $values
* @param array<string> $columns
* @param array<string> $values
* @param array<string, string> $options
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = [])
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Navigation/FaqNavigationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected function findCurrent(): ?FaqModel
}

/**
* @param array<string> $columns
* @param array<string> $values
* @param array<string> $columns
* @param array<string> $values
* @param array<string, string> $options
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = []): ?FaqModel
Expand Down
5 changes: 2 additions & 3 deletions src/EventListener/Navigation/NewsNavigationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ protected function findCurrent(): ?NewsModel
}

/**
* @param array<string> $columns
* @param array<string> $values
* @param array<string> $columns
* @param array<string> $values
* @param array<string, string> $options
* @return NewsModel|null
*/
protected function findPublishedBy(array $columns, array $values = [], array $options = []): ?NewsModel
{
Expand Down
5 changes: 4 additions & 1 deletion src/FrontendModule/ChangeLanguageModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ protected function generateTemplateArray(NavigationItem $item, UrlParameterBag $
];
}

/**
* @param array<array<string, int|string>> $items
*/
protected function generateNavigationTemplate(array $items): string
{
$objTemplate = new FrontendTemplate($this->navigationTpl ?: 'nav_default');
Expand All @@ -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<string, int|string> $queryParameters An array of query parameters to keep
*/
protected function createUrlParameterBag(array $queryParameters = []): UrlParameterBag
{
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/LabelCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public static function createAndRegister(string $table, callable $callback): sel
}

/**
* @param callable|array $callback
* @param array<mixed> $args
* @param callable|array<string, string> $callback
* @param array<mixed> $args
*
* @return mixed
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]) : '');
Expand Down
8 changes: 4 additions & 4 deletions src/Navigation/NavigationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]),
);
}

Expand Down Expand Up @@ -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));
Expand All @@ -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])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Navigation/NavigationItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions src/Navigation/UrlParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
class UrlParameterBag
{
/**
* @var array<int|float|string|bool>
* @var array<string, int|float|string|bool>
*/
private array $attributes;

/**
* @var array<string, int|float|string|bool|array<int|float|string|bool>>
*/
private array $query;

/**
* @param array<string, int|float|string|bool> $attributes Route parameters (e.g. items=foobar in /alias/items/foobar.html)
* @param array<string, string> $query The URL query parameters
* @param array<string, int|float|string|bool> $attributes Route parameters (e.g. items=foobar in /alias/items/foobar.html)
* @param array<string, int|float|string|bool|array<int|float|string|bool>> $query The URL query parameters
*/
public function __construct(array $attributes = [], array $query = [])
{
Expand Down Expand Up @@ -72,11 +75,17 @@ public function removeUrlAttribute(string $name): void
unset($this->attributes[$name]);
}

/**
* @return array<string, int|float|string|bool|array<int|float|string|bool>>
*/
public function getQueryParameters(): array
{
return $this->query;
}

/**
* @param array<string, int|float|string|bool|array<int|float|string|bool>> $query
*/
public function setQueryParameters(array $query): void
{
$this->validateScalar($query);
Expand Down
Loading

0 comments on commit 7cbee41

Please sign in to comment.