Skip to content

Commit f6ade03

Browse files
committed
Rector
1 parent 0c009ab commit f6ade03

12 files changed

Lines changed: 50 additions & 104 deletions

File tree

contao/dca/tl_cfg_tag.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(strict_types=1);
44

55
use Codefog\TagsBundle\Driver;
6+
use Contao\DataContainer;
67

78
/*
89
* Tags Bundle for Contao Open Source CMS.
@@ -33,9 +34,9 @@
3334
// List
3435
'list' => [
3536
'sorting' => [
36-
'mode' => 1,
37+
'mode' => DataContainer::MODE_SORTED,
3738
'fields' => ['name'],
38-
'flag' => 1,
39+
'flag' => DataContainer::SORT_INITIAL_LETTER_ASC,
3940
'panelLayout' => 'filter;cfg_sort,search,limit',
4041
'panel_callback' => [
4142
'cfg_sort' => ['codefog_tags.listener.data_container.tag', 'onPanelCallback'],

src/DependencyInjection/Compiler/ManagerPass.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,13 @@ class ManagerPass implements CompilerPassInterface
1212
{
1313
public const TAG_NAME = 'codefog_tags.manager';
1414

15-
/**
16-
* @var string
17-
*/
18-
private $registryName;
19-
2015
/**
2116
* ManagerPass constructor.
2217
*
2318
* @param string $registryName
2419
*/
25-
public function __construct($registryName)
20+
public function __construct(private $registryName)
2621
{
27-
$this->registryName = $registryName;
2822
}
2923

3024
public function process(ContainerBuilder $container): void

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function getConfigTreeBuilder(): TreeBuilder
1717
$rootNode = $treeBuilder->getRootNode();
1818
} else {
1919
// BC layer for symfony/config 4.1 and older
20-
$rootNode = $treeBuilder->root('codefog_tags');
20+
$rootNode = $treeBuilder->getRootNode();
2121
}
2222

2323
$rootNode

src/EventListener/DataContainer/TagListener.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,14 @@
2121

2222
class TagListener
2323
{
24-
/**
25-
* @var Connection
26-
*/
27-
private $db;
28-
29-
/**
30-
* @var ManagerRegistry
31-
*/
32-
private $registry;
33-
34-
/**
35-
* @var RequestStack
36-
*/
37-
private $requestStack;
38-
3924
/**
4025
* TagListener constructor.
4126
*/
42-
public function __construct(Connection $db, ManagerRegistry $registry, RequestStack $requestStack)
43-
{
44-
$this->db = $db;
45-
$this->registry = $registry;
46-
$this->requestStack = $requestStack;
27+
public function __construct(
28+
private readonly Connection $db,
29+
private readonly ManagerRegistry $registry,
30+
private readonly RequestStack $requestStack,
31+
) {
4732
}
4833

4934
/**

src/EventListener/InsertTagsListener.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,11 @@
99

1010
class InsertTagsListener
1111
{
12-
/**
13-
* @var ManagerRegistry
14-
*/
15-
private $registry;
16-
1712
/**
1813
* TagContainer constructor.
1914
*/
20-
public function __construct(ManagerRegistry $registry)
15+
public function __construct(private readonly ManagerRegistry $registry)
2116
{
22-
$this->registry = $registry;
2317
}
2418

2519
/**

src/EventListener/TagManagerListener.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,11 @@
2020

2121
class TagManagerListener
2222
{
23-
/**
24-
* @var ManagerRegistry
25-
*/
26-
private $registry;
27-
28-
/**
29-
* @var RequestStack
30-
*/
31-
private $requestStack;
32-
33-
/**
34-
* @var ScopeMatcher
35-
*/
36-
private $scopeMatcher;
37-
38-
public function __construct(ManagerRegistry $registry, RequestStack $requestStack, ScopeMatcher $scopeMatcher)
39-
{
40-
$this->registry = $registry;
41-
$this->requestStack = $requestStack;
42-
$this->scopeMatcher = $scopeMatcher;
23+
public function __construct(
24+
private readonly ManagerRegistry $registry,
25+
private readonly RequestStack $requestStack,
26+
private readonly ScopeMatcher $scopeMatcher,
27+
) {
4328
}
4429

4530
/**

src/Finder/SourceFinder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
class SourceFinder
2020
{
2121
public function __construct(
22-
private Connection $connection,
23-
private DcaRelationsManager $dcaRelationsManager,
22+
private readonly Connection $connection,
23+
private readonly DcaRelationsManager $dcaRelationsManager,
2424
) {
2525
}
2626

@@ -47,7 +47,7 @@ public function findMultiple(SourceCriteria $criteria): array
4747
$values = DcaRelationsModel::getReferenceValues($criteria->getSourceTable(), $criteria->getSourceField(), $ids);
4848
$values = array_values(array_unique($values));
4949

50-
return array_map('intval', $values);
50+
return array_map(intval(...), $values);
5151
}
5252

5353
/**
@@ -67,7 +67,7 @@ public function findRelatedSourceRecords(SourceCriteria $criteria, int|null $lim
6767

6868
$tagIds = DcaRelationsModel::getRelatedValues($criteria->getSourceTable(), $criteria->getSourceField(), $criteria->getIds());
6969
$tagIds = array_values(array_unique($tagIds));
70-
$tagIds = array_map('intval', $tagIds);
70+
$tagIds = array_map(intval(...), $tagIds);
7171

7272
if (0 === \count($tagIds)) {
7373
return [];

src/Finder/TagFinder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function count(TagCriteria $criteria): int
2626
{
2727
try {
2828
[$columns, $values, $options] = $this->parseCriteria($criteria);
29-
} catch (NoTagsException $e) {
29+
} catch (NoTagsException) {
3030
return 0;
3131
}
3232

@@ -44,7 +44,7 @@ public function findSingle(TagCriteria $criteria): Tag|null
4444
{
4545
try {
4646
[$columns, $values, $options] = $this->parseCriteria($criteria);
47-
} catch (NoTagsException $e) {
47+
} catch (NoTagsException) {
4848
return null;
4949
}
5050

@@ -62,7 +62,7 @@ public function findMultiple(TagCriteria $criteria): array
6262
{
6363
try {
6464
[$columns, $values, $options] = $this->parseCriteria($criteria);
65-
} catch (NoTagsException $e) {
65+
} catch (NoTagsException) {
6666
return [];
6767
}
6868

@@ -115,7 +115,7 @@ public function getTopTagIds(TagCriteria $criteria, int|null $limit = null, bool
115115
{
116116
// No array_unique() here!
117117
$tagIds = DcaRelationsModel::getRelatedValues($criteria->getSourceTable(), $criteria->getSourceField(), $criteria->getSourceIds());
118-
$tagIds = array_map('intval', $tagIds);
118+
$tagIds = array_map(intval(...), $tagIds);
119119

120120
if (0 === \count($tagIds)) {
121121
return [];
@@ -168,7 +168,7 @@ protected function parseCriteria(TagCriteria $criteria): array
168168
$columns[] = 'id=?';
169169
$values[] = (int) $ids[0];
170170
} else {
171-
$columns[] = 'id IN ('.implode(',', array_map('intval', $ids)).')';
171+
$columns[] = 'id IN ('.implode(',', array_map(intval(...), $ids)).')';
172172
}
173173
}
174174

@@ -186,7 +186,7 @@ protected function parseCriteria(TagCriteria $criteria): array
186186
if (\count($sourceIds = $criteria->getSourceIds()) > 0) {
187187
$ids = DcaRelationsModel::getRelatedValues($criteria->getSourceTable(), $criteria->getSourceField(), $sourceIds);
188188
$ids = array_values(array_unique($ids));
189-
$ids = array_map('intval', $ids);
189+
$ids = array_map(intval(...), $ids);
190190

191191
if (0 === \count($ids)) {
192192
throw new NoTagsException();
@@ -202,7 +202,7 @@ protected function parseCriteria(TagCriteria $criteria): array
202202
if ($criteria->isUsedOnly()) {
203203
$ids = DcaRelationsModel::getRelatedValues($criteria->getSourceTable(), $criteria->getSourceField());
204204
$ids = array_values(array_unique($ids));
205-
$ids = array_map('intval', $ids);
205+
$ids = array_map(intval(...), $ids);
206206

207207
if (0 === \count($ids)) {
208208
throw new NoTagsException();

src/Manager/DefaultManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getFilteredTags(array $values, string|null $source = null): arra
8383

8484
public function updateDcaField(string $table, string $field, array &$config): void
8585
{
86-
$config['eval']['tagsCreate'] = $config['eval']['tagsCreate'] ?? true;
86+
$config['eval']['tagsCreate'] ??= true;
8787

8888
// Set the relation
8989
if (!isset($config['sql'])) {

src/Tag.php

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,23 @@
66

77
class Tag
88
{
9-
/**
10-
* Tag ID.
11-
*
12-
* @var string
13-
*/
14-
private $value;
15-
16-
/**
17-
* Tag name.
18-
*
19-
* @var string
20-
*/
21-
private $name;
22-
23-
/**
24-
* Data.
25-
*
26-
* @var array
27-
*/
28-
private $data;
29-
309
/**
3110
* Tag constructor.
3211
*/
33-
public function __construct(string $value, string $name, array $data = [])
34-
{
35-
$this->value = $value;
36-
$this->name = $name;
37-
$this->data = $data;
12+
public function __construct(
13+
/**
14+
* Tag ID.
15+
*/
16+
private string $value,
17+
/**
18+
* Tag name.
19+
*/
20+
private string $name,
21+
/**
22+
* Data.
23+
*/
24+
private array $data = [],
25+
) {
3826
}
3927

4028
public function getValue(): string

0 commit comments

Comments
 (0)