Skip to content

Commit 5636493

Browse files
committed
Do not transfer Options object to methods
1 parent 757a8df commit 5636493

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

lib/Form/ContentTypeType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function configureOptions(OptionsResolver $resolver): void
2525

2626
$resolver->setDefault(
2727
'choices',
28-
fn (Options $options): array => $this->getContentTypes($options),
28+
fn (Options $options): array => $this->getContentTypes($options['types']),
2929
);
3030

3131
$resolver->setDefault('choice_translation_domain', false);
@@ -45,14 +45,15 @@ public function getParent(): string
4545
/**
4646
* Returns the allowed content types from Ibexa CMS.
4747
*
48+
* @param array<string, string[]|bool> $configuredGroups
49+
*
4850
* @return array<string, string[]>
4951
*/
50-
private function getContentTypes(Options $options): array
52+
private function getContentTypes(array $configuredGroups): array
5153
{
5254
$allContentTypes = [];
5355

5456
$groups = $this->contentTypeService->loadContentTypeGroups();
55-
$configuredGroups = $options['types'];
5657

5758
foreach ($groups as $group) {
5859
$configuredGroups += [$group->identifier => true];

lib/Form/ObjectStateType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function configureOptions(OptionsResolver $resolver): void
2525

2626
$resolver->setDefault(
2727
'choices',
28-
fn (Options $options): array => $this->getObjectStates($options),
28+
fn (Options $options): array => $this->getObjectStates($options['states']),
2929
);
3030

3131
$resolver->setDefault('choice_translation_domain', false);
@@ -45,14 +45,15 @@ public function getParent(): string
4545
/**
4646
* Returns the allowed content states from Ibexa CMS.
4747
*
48+
* @param array<string, string[]|bool> $configuredGroups
49+
*
4850
* @return array<string, string[]>
4951
*/
50-
private function getObjectStates(Options $options): array
52+
private function getObjectStates(array $configuredGroups): array
5153
{
5254
$allObjectStates = [];
5355

5456
$groups = $this->objectStateService->loadObjectStateGroups();
55-
$configuredGroups = $options['states'];
5657

5758
foreach ($groups as $group) {
5859
$configuredGroups += [$group->identifier => true];

lib/Form/SectionType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function configureOptions(OptionsResolver $resolver): void
2525

2626
$resolver->setDefault(
2727
'choices',
28-
fn (Options $options): array => $this->getSections($options),
28+
fn (Options $options): array => $this->getSections($options['sections']),
2929
);
3030

3131
$resolver->setDefault('choice_translation_domain', false);
@@ -45,15 +45,16 @@ public function getParent(): string
4545
/**
4646
* Returns the allowed sections from Ibexa CMS.
4747
*
48+
* @param array<string, string[]> $configuredSections
49+
*
4850
* @return array<string, string>
4951
*/
50-
private function getSections(Options $options): array
52+
private function getSections(array $configuredSections): array
5153
{
5254
$allSections = [];
5355

5456
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Section[] $sections */
5557
$sections = $this->sectionService->loadSections();
56-
$configuredSections = $options['sections'];
5758

5859
foreach ($sections as $section) {
5960
if (count($configuredSections) > 0 && !in_array($section->identifier, $configuredSections, true)) {

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ parameters:
77
ignoreErrors:
88
# Symfony
99

10-
- '#with generic interface Symfony\\Component\\(Form|OptionsResolver)\\\w+ but does not specify its types: (TData|TArray)#'
10+
- '#with generic interface Symfony\\Component\\Form\\\w+ but does not specify its types: TData#'
1111
- '#extends generic class Symfony\\Component\\Form\\\w+ but does not specify its types: TData#'

0 commit comments

Comments
 (0)