Skip to content

Commit

Permalink
add tools config and run rector
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Nov 5, 2024
1 parent 556b2ca commit f7b2f7f
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Context**
Contao version:
Bundle version:
PHP version:

**Description**
<!-- Please describe the issue and provide reproduction steps (in a clean contao installation). If you report an error, please provide the full error message (ideally a screenshot of the error page in dev mode) -->
4 changes: 1 addition & 3 deletions src/Controller/ListWidgetContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ public function applyListConfigToCriteria(Criteria $criteria, array $fields): vo
public function adjustDataResultStructure(array &$data): void
{
array_walk($data, function (&$date) {
$date = array_map(function ($value) {
return ['value' => $value];
}, array_values($date));
$date = array_map(fn($value) => ['value' => $value], array_values($date));
});
}

Expand Down
12 changes: 4 additions & 8 deletions src/Widget/ListWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function prepareConfig($arrConfig = [], $objContext = null, $objDc
}


public static function initAjaxLoading(array $arrConfig, $objContext = null, $objDc = null)
public static function initAjaxLoading(array $arrConfig, $objContext = null, $objDc = null): void
{
$request = System::getContainer()->get('huh.request');
$dcaUtil = System::getContainer()->get('huh.utils.dca');
Expand All @@ -148,9 +148,7 @@ public static function initAjaxLoading(array $arrConfig, $objContext = null, $ob

// start loading
if (!isset($arrConfig['ajaxConfig']['load_items_callback'])) {
$arrConfig['ajaxConfig']['load_items_callback'] = function () use ($arrConfig, $objContext, $objDc) {
return self::loadItems($arrConfig, [], $objContext, $objDc);
};
$arrConfig['ajaxConfig']['load_items_callback'] = fn() => self::loadItems($arrConfig, [], $objContext, $objDc);
}

$strResult = $dcaUtil->getConfigByArrayOrCallbackOrFunction(
Expand Down Expand Up @@ -200,7 +198,7 @@ public static function addToTemplate(Template $objTemplate, array $configuration
);
} else {
$objTemplate->processingAction = System::getContainer()->get(Utils::class)->url()->addQueryStringParameterToUrl(
'key=' . static::LOAD_ACTION . '&scope=' . $configuration['identifier'] . '&rt=' . RequestToken::get());
'key=' . static::LOAD_ACTION . '&scope=' . $configuration['identifier'] . '&rt=' . \Contao\System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue());
}
} else {
$objTemplate->items = $configuration['items'];
Expand Down Expand Up @@ -237,9 +235,7 @@ public static function loadItems($arrConfig, $arrOptions = [], $objContext = nul

// prepare
if (!isset($arrConfig['ajaxConfig']['prepare_items_callback'])) {
$arrConfig['ajaxConfig']['prepare_items_callback'] = function () use ($objItems, $arrConfig, $arrOptions, $objContext, $objDc) {
return self::prepareItems($objItems, $arrConfig, $arrOptions, $objContext, $objDc);
};
$arrConfig['ajaxConfig']['prepare_items_callback'] = fn() => self::prepareItems($objItems, $arrConfig, $arrOptions, $objContext, $objDc);
}

$arrResponse['data'] = System::getContainer()->get('huh.utils.dca')->getConfigByArrayOrCallbackOrFunction(
Expand Down
2 changes: 2 additions & 0 deletions tools/ecs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
5 changes: 5 additions & 0 deletions tools/ecs/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"symplify/easy-coding-standard": "^12.1"
}
}
39 changes: 39 additions & 0 deletions tools/ecs/ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\Basic\BracesPositionFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withPaths([
__DIR__ . '/../../src',
])

// add a single rule
->withRules([
NoUnusedImportsFixer::class,
BracesPositionFixer::class,
])

// add sets - group of rules
->withPreparedSets(
arrays: true,
namespaces: true,
spaces: true,
docblocks: true,
comments: true,
// psr12: true,
)
->withSkip([
NotOperatorWithSuccessorSpaceFixer::class
])

;
2 changes: 2 additions & 0 deletions tools/rector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
6 changes: 6 additions & 0 deletions tools/rector/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"rector/rector": "^1.0",
"contao/contao-rector": "dev-main"
}
}
30 changes: 30 additions & 0 deletions tools/rector/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Contao\Rector\Set\ContaoLevelSetList;
use Contao\Rector\Set\ContaoSetList;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/../../src',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
])
->withSets([
SetList::PHP_81,
LevelSetList::UP_TO_PHP_81,
SymfonySetList::SYMFONY_54,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
ContaoSetList::CONTAO_413,
ContaoSetList::FQCN,
ContaoLevelSetList::UP_TO_CONTAO_413,
]);

0 comments on commit f7b2f7f

Please sign in to comment.