Skip to content

Commit 8616799

Browse files
authored
Update / Improvement (#405)
1 parent 7289c49 commit 8616799

File tree

8 files changed

+18
-19
lines changed

8 files changed

+18
-19
lines changed

.php-cs-fixer.dist.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
'phpdoc_var_without_name' => true,
5252
'phpdoc_to_comment' => false,
5353
'single_line_throw' => true,
54-
'string_implicit_backslashes' => false, // Temporary?
5554
'statement_indentation' => true,
5655
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'parameters']],
5756
'use_arrow_functions' => true,

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
"phpstan/phpstan-phpunit": "^2.0.10",
5252
"phpstan/phpstan-strict-rules": "^2.0.7",
5353
"phpstan/phpstan-symfony": "^2.0.9",
54-
"phpunit/phpunit": "^12.5.2",
54+
"phpunit/phpunit": "^13.0.5",
5555
"rector/rector": "^2.2.14",
5656
"stof/doctrine-extensions-bundle": "^1.14",
57-
"symfony/cache": "^7.4.1|^8.0.1",
58-
"symfony/validator": "^7.4|^8.0.2",
59-
"symfony/var-dumper": "^7.4"
57+
"symfony/cache": "^7.4|^8.0",
58+
"symfony/validator": "^7.4|^8.0",
59+
"symfony/var-dumper": "^7.4|^8.0"
6060
},
6161
"suggest": {
6262
"knplabs/doctrine-behaviors": "For Knp strategy",

src/Form/Type/TranslationsFormsType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
7272
}
7373

7474
$translation->locale = $locale; // @phpstan-ignore property.notFound
75-
$translationColl->add($translation);
75+
$translationColl->set($locale, $translation);
7676
},
7777
// LocaleExtension options process
7878
'label' => $options['locale_labels'][$locale] ?? null,

src/Form/Type/TranslationsType.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private function buildKnp(FormBuilderInterface $builder, array $options): void
160160

161161
$localeFormBuilder = $builder->create($locale, FormType::class, [
162162
'data_class' => $options['translation_class'],
163-
'setter' => static fn (...$args) => self::knpLocaleSetter($locale, $required, ...$args), // @phpstan-ignore argument.unpackNonIterable, argument.type
163+
'setter' => static fn (...$args) => self::knpLocaleSetter($locale, $required, ...$args), // @phpstan-ignore argument.type
164164
// LocaleExtension options process
165165
'label' => $options['locale_labels'][$locale] ?? null,
166166
'required' => $required,
@@ -201,8 +201,8 @@ private function buildGedmo(FormBuilderInterface $builder, array $options): void
201201
? [
202202
'inherit_data' => true,
203203
] : [
204-
'getter' => static fn (...$args) => self::gedmoLocaleGetter($locale, ...$args), // @phpstan-ignore argument.unpackNonIterable, argument.type
205-
'setter' => static fn (...$args) => self::gedmoLocaleSetter(...$args), // @phpstan-ignore argument.unpackNonIterable, argument.type
204+
'getter' => static fn (...$args) => self::gedmoLocaleGetter($locale, ...$args), // @phpstan-ignore argument.type
205+
'setter' => static fn (...$args) => self::gedmoLocaleSetter(...$args), // @phpstan-ignore argument.type
206206
]
207207
),
208208
// LocaleExtension options process
@@ -222,7 +222,7 @@ private function buildGedmo(FormBuilderInterface $builder, array $options): void
222222
$field = $builtChild->getName();
223223
$localeFormBuilder->add($builtChild->getName(), $builtChild->getType()->getInnerType()::class, [
224224
...$builtChild->getFormConfig()->getOptions(),
225-
'getter' => static fn (...$args) => self::gedmoFieldGetter($field, ...$args), // @phpstan-ignore argument.unpackNonIterable, argument.type
225+
'getter' => static fn (...$args) => self::gedmoFieldGetter($field, ...$args), // @phpstan-ignore argument.type
226226
'setter' => static fn (array &$translations, ?string $data) => self::gedmoFieldSetter($field, $locale, $translationClass, $translations, $data), // @phpstan-ignore-line
227227
// 'property_path' => sprintf('[%s?].content', $field),
228228
]);
@@ -233,8 +233,8 @@ private function buildGedmo(FormBuilderInterface $builder, array $options): void
233233
}
234234

235235
/**
236-
* @param Collection<int, \Stub\KnpTranslation> $translationColl
237-
* @param ?\Stub\KnpTranslation $translation
236+
* @param Collection<array-key, \Stub\KnpTranslation> $translationColl
237+
* @param ?\Stub\KnpTranslation $translation
238238
*/
239239
private static function knpLocaleSetter(string $locale, bool $required, Collection $translationColl, ?object $translation): void
240240
{
@@ -249,7 +249,7 @@ private static function knpLocaleSetter(string $locale, bool $required, Collecti
249249
}
250250

251251
$translation->setLocale($locale);
252-
$translationColl->add($translation);
252+
$translationColl->set($locale, $translation);
253253
}
254254

255255
/**

stubs/GedmoTranslatable.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Doctrine\Common\Collections\Collection;
77
interface GedmoTranslatable
88
{
99
/**
10-
* @return Collection<int, GedmoTranslation>
10+
* @return Collection<array-key, GedmoTranslation>
1111
*/
1212
public function getTranslations(): Collection;
1313
public function addTranslation(GedmoTranslation $translation): self;

tests/Fixtures/Entity/Company.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class Company implements TranslatableInterface
3434
#[AutoTypeCustom(options: ['priority' => 1])]
3535
protected $translations;
3636

37-
/** @var Collection<int, Category> */
37+
/** @var Collection<array-key, Category> */
3838
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'company', cascade: ['all'], orphanRemoval: true)]
3939
#[AutoTypeCustom(options: ['entry_options' => ['label' => false]], embedded: true)]
4040
public Collection $categories;
4141

42-
/** @var Collection<int, CompanyMediaLocale> */
42+
/** @var Collection<array-key, CompanyMediaLocale> */
4343
#[ORM\OneToMany(targetEntity: CompanyMediaLocale::class, mappedBy: 'company', cascade: ['all'], orphanRemoval: true, indexBy: 'locale')]
4444
// #[AutoTypeCustom(embedded: true, options: ['entry_options' => ['label' => false, 'children_excluded' => ['id']]])]
4545
// #[AutoTypeCustom(options: ['form_type' => CompanyMediaType::class], type: TranslationsFormsType::class)]

tests/Fixtures/Entity/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Product
4040
#[ORM\ManyToOne(targetEntity: Category::class, cascade: ['all'])]
4141
public ?Category $category = null;
4242

43-
/** @var Collection<int, ProductTranslation> */
43+
/** @var Collection<array-key, ProductTranslation> */
4444
#[ORM\OneToMany(targetEntity: ProductTranslation::class, mappedBy: 'object', cascade: ['persist', 'remove'], orphanRemoval: true)]
4545
#[AutoTypeCustom(options: ['priority' => 1])]
4646
public Collection $translations;
@@ -51,7 +51,7 @@ public function __construct()
5151
}
5252

5353
/**
54-
* @return Collection<int, ProductTranslation>
54+
* @return Collection<array-key, ProductTranslation>
5555
*/
5656
public function getTranslations(): Collection
5757
{

tests/Form/TypeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function setUpBeforeClass(): void
6969
}
7070

7171
/**
72-
* @param array<array-key, FormInterface<mixed>> $formChildren
72+
* @param array<array-key, \Symfony\Component\Form\FormInterface<mixed>> $formChildren
7373
*/
7474
protected static function assertFormChildren(array $expectedForm, array $formChildren, string $parentPath = ''): void
7575
{

0 commit comments

Comments
 (0)