Skip to content

Commit

Permalink
Update build tools and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Aug 29, 2024
1 parent 89761f7 commit 155615c
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 34 deletions.
9 changes: 0 additions & 9 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

return (new Configuration())
->ignoreErrorsOnPackage('doctrine/dbal', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/config', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/dependency-injection', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/event-dispatcher-contracts', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/http-kernel', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/routing', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/security-core', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/service-contracts', [ErrorType::SHADOW_DEPENDENCY])

// Optional integrations
->ignoreErrorsOnPackage('contao/calendar-bundle', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreErrorsOnPackage('contao/faq-bundle', [ErrorType::DEV_DEPENDENCY_IN_PROD])
Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@
"php": "^7.4 || ^8.0",
"contao/core-bundle": "^4.13.25 || ^5.0",
"league/uri": "^6.0 || ^7.0",
"league/uri-components": "^2.0 || ^7.0"
"league/uri-components": "^2.0 || ^7.0",
"doctrine/dbal": "^3.3",
"symfony/config": "^5.0 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0",
"symfony/event-dispatcher-contracts": "^2.0 || ^3.0",
"symfony/http-kernel": "^5.0 || ^6.0 || ^7.0",
"symfony/routing": "^5.0 || ^6.0 || ^7.0",
"symfony/security-core": "^5.0 || ^6.0 || ^7.0",
"symfony/service-contracts": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"terminal42/contao-build-tools": "dev-main",
Expand Down
8 changes: 2 additions & 6 deletions src/Event/ChangelanguageNavigationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ public function __construct(NavigationItem $navigationItem, UrlParameterBag $url

/**
* Gets the navigation item for this event.
*
* @return NavigationItem
*/
public function getNavigationItem()
public function getNavigationItem(): NavigationItem
{
return $this->navigationItem;
}

/**
* Gets the UrlParameterBag for this navigation item.
*
* @return UrlParameterBag
*/
public function getUrlParameterBag()
public function getUrlParameterBag(): UrlParameterBag
{
return $this->urlParameterBag;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/BackendView/ArticleViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function getAvailableLanguages(PageModel $page): array

$articles = array_values(array_filter(
$articles,
fn (ArticleModel $article) => $article->inColumn === $this->currentArticle->inColumn,
fn (ArticleModel $article): bool => $article->inColumn === $this->currentArticle->inColumn,
));

if (1 === \count($articles)) {
Expand Down
8 changes: 2 additions & 6 deletions src/EventListener/BackendView/ParentChildViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ParentChildViewListener extends AbstractViewListener
*/
private $current = false;

protected function isSupported()
protected function isSupported(): bool
{
return $this->getTable() === Input::get('table') && (
('news' === Input::get('do') && InstalledVersions::isInstalled('contao/news-bundle'))
Expand Down Expand Up @@ -104,12 +104,8 @@ protected function doSwitchView($id): void

/**
* Finds related item for a given page.
*
* @param int $id
*
* @return Model|null
*/
private function findRelatedForPageAndId(PageModel $page, $id)
private function findRelatedForPageAndId(PageModel $page, int $id): ?Model
{
/** @var Model $class */
$class = $this->getModelClass();
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DataContainer/ParentTableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register(): void
'label' => &$GLOBALS['TL_LANG'][$this->table]['master'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => fn (DataContainer $dc) => $this->onMasterOptions($dc),
'options_callback' => fn (DataContainer $dc): array => $this->onMasterOptions($dc),
'eval' => [
'includeBlankOption' => true,
'blankOptionLabel' => &$GLOBALS['TL_LANG'][$this->table]['isMaster'],
Expand Down
8 changes: 2 additions & 6 deletions src/EventListener/Navigation/ArticleNavigationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __invoke(ChangelanguageNavigationEvent $event): void

$targetArticle = $this->findTargetArticle(
$currentArticle,
$targetRoot->id,
(int) $targetRoot->id,
$objPage->rootId === $masterRoot->id,
null !== $masterRoot && $targetRoot->id === $masterRoot->id,
);
Expand All @@ -71,12 +71,8 @@ public function __invoke(ChangelanguageNavigationEvent $event): void

/**
* Find target article for a root page and current article.
*
* @param int $targetRootId
* @param bool $currentIsFallback
* @param bool $targetIsFallback
*/
private function findTargetArticle(ArticleModel $currentArticle, $targetRootId, $currentIsFallback, $targetIsFallback): ?ArticleModel
private function findTargetArticle(ArticleModel $currentArticle, int $targetRootId, bool $currentIsFallback, bool $targetIsFallback): ?ArticleModel
{
// If the target root is fallback, the article ID will match our current "languageMain"
if ($targetIsFallback) {
Expand Down
3 changes: 1 addition & 2 deletions src/FrontendModule/ChangeLanguageModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Terminal42\ChangeLanguage\FrontendModule;

use Contao\ArrayUtil;
use Contao\BackendTemplate;
use Contao\FrontendTemplate;
use Contao\Input;
Expand Down Expand Up @@ -212,7 +211,7 @@ protected function createUrlParameterBag(array $queryParameters = []): UrlParame
array_unshift($fragments, 'auto_item');
}

for ($i=0, $c=\count($fragments); $i<$c; $i+=2) {
for ($i = 0, $c = \count($fragments); $i < $c; $i += 2) {
$attributes[$fragments[$i]] = $fragments[$i + 1];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/LanguageText.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function orderNavigationItems(array &$items): void

usort(
$items,
static function (NavigationItem $a, NavigationItem $b) use ($languages) {
static function (NavigationItem $a, NavigationItem $b) use ($languages): int {
$key1 = array_search(strtolower($a->getLocaleId()), $languages, true);
$key2 = array_search(strtolower($b->getLocaleId()), $languages, true);

Expand Down
2 changes: 1 addition & 1 deletion src/PageFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function findAssociatedForPage(PageModel $page, bool $skipCurrent = false

return array_filter(
$this->findPages($columns, $values),
static function (PageModel $page) use ($rootPages) {
static function (PageModel $page) use ($rootPages): bool {
$page->loadDetails();

return \array_key_exists($page->rootId, $rootPages);
Expand Down

0 comments on commit 155615c

Please sign in to comment.