Skip to content

Commit be99900

Browse files
#234: Fixed PHPStan issues
1 parent 5d6b8cd commit be99900

12 files changed

+41
-59
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"darkwebdesign/symfony-addon-transformers": "6.0.*",
1919
"doctrine/orm": "^2.7",
2020
"phpstan/phpstan": "^1.11",
21+
"phpstan/phpstan-doctrine": "^1.4",
22+
"phpstan/phpstan-phpunit": "^1.4",
23+
"phpstan/phpstan-symfony": "^1.4",
2124
"phpunit/phpunit": "^9.5",
2225
"rector/rector": "^1.1"
2326
},

phpstan.neon

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
includes:
2+
- 'vendor/phpstan/phpstan-doctrine/extension.neon'
3+
- 'vendor/phpstan/phpstan-phpunit/extension.neon'
4+
- 'vendor/phpstan/phpstan-symfony/extension.neon'
5+
16
parameters:
2-
level: 1
7+
level: 8
8+
39
paths:
4-
- src
5-
- tests
10+
- 'src'
11+
- 'tests'

rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
SymfonySetList::SYMFONY_60,
1717
])
1818
->withImportNames(
19-
importDocBlockNames: false,
2019
importShortClasses: false,
2120
);

src/BirthdayType.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,19 @@
2727
use Symfony\Component\OptionsResolver\OptionsResolver;
2828

2929
/**
30-
* Birthday form field type.
31-
*
3230
* @author Raymond Schouten
3331
*
3432
* @since 2.3
3533
*/
3634
class BirthdayType extends AbstractType
3735
{
38-
/**
39-
* Configures the options for this type.
40-
*/
4136
public function configureOptions(OptionsResolver $resolver): void
4237
{
4338
$resolver->setDefaults([
4439
'years' => range(date('Y'), date('Y') - 120),
4540
]);
4641
}
4742

48-
/**
49-
* Returns the name of the parent type.
50-
*/
5143
public function getParent(): string
5244
{
5345
return DateType::class;

src/BooleanToYesNoSubscriber.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
use Symfony\Component\Form\FormEvents;
2828

2929
/**
30-
* Boolean to "yes" or "no" form event subscriber.
31-
*
3230
* @author Raymond Schouten
3331
*
3432
* @since 5.2.1
@@ -63,9 +61,6 @@ public function onPreSubmit(FormEvent $event): void
6361
$event->setData($data);
6462
}
6563

66-
/**
67-
* Returns an array of event names this subscriber wants to listen to.
68-
*/
6964
public static function getSubscribedEvents(): array
7065
{
7166
return [

src/BooleanType.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,12 @@
3030
use Symfony\Component\OptionsResolver\OptionsResolver;
3131

3232
/**
33-
* Boolean form field type.
34-
*
3533
* @author Raymond Schouten
3634
*
3735
* @since 2.3
3836
*/
3937
class BooleanType extends AbstractType
4038
{
41-
/**
42-
* Builds the form.
43-
*/
4439
public function buildForm(FormBuilderInterface $builder, array $options): void
4540
{
4641
if (!class_exists(BooleanToValueTransformer::class)) {
@@ -50,9 +45,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5045
$builder->addModelTransformer(new BooleanToValueTransformer($options['value_true'], $options['value_false']));
5146
}
5247

53-
/**
54-
* Configures the options for this type.
55-
*/
5648
public function configureOptions(OptionsResolver $resolver): void
5749
{
5850
$labelTrueNormalizer = fn(Options $options, $value) =>
@@ -92,9 +84,6 @@ public function configureOptions(OptionsResolver $resolver): void
9284
$resolver->setAllowedValues('widget', ['choice', 'radio']);
9385
}
9486

95-
/**
96-
* Returns the name of the parent type.
97-
*/
9887
public function getParent(): string
9988
{
10089
return ChoiceType::class;
@@ -105,6 +94,6 @@ public function getParent(): string
10594
*/
10695
public function humanize(string $text): string
10796
{
108-
return ucfirst(trim(strtolower(preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $text))));
97+
return ucfirst(trim(strtolower((string) preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $text))));
10998
}
11099
}

src/EntityType.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
// @codeCoverageIgnoreEnd
3939

4040
/**
41-
* Entity form field type.
42-
*
4341
* @author Raymond Schouten
4442
*
4543
* @since 2.3
@@ -51,9 +49,6 @@ public function __construct(
5149
) {
5250
}
5351

54-
/**
55-
* Builds the form.
56-
*/
5752
public function buildForm(FormBuilderInterface $builder, array $options): void
5853
{
5954
if (!class_exists(EntityToIdentifierTransformer::class)) {
@@ -63,9 +58,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6358
$builder->addViewTransformer(new EntityToIdentifierTransformer($options['entity_manager'], $options['class']));
6459
}
6560

66-
/**
67-
* Configures the options for this type.
68-
*/
6961
public function configureOptions(OptionsResolver $resolver): void
7062
{
7163
if (!interface_exists(ObjectManager::class)) {

src/JsonSchemaSubscriber.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
use Symfony\Component\Form\FormEvents;
2828

2929
/**
30-
* JSON Schema form event subscriber.
31-
*
3230
* @author Raymond Schouten
3331
*
3432
* @since 5.2.1
@@ -57,9 +55,6 @@ public function onPreSubmit(FormEvent $event): void
5755
$event->setData($data);
5856
}
5957

60-
/**
61-
* Returns an array of event names this subscriber wants to listen to.
62-
*/
6358
public static function getSubscribedEvents(): array
6459
{
6560
return [

src/UnstructuredType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,12 @@
2626
use Symfony\Component\OptionsResolver\OptionsResolver;
2727

2828
/**
29-
* Unstructured form field type.
30-
*
3129
* @author Raymond Schouten
3230
*
3331
* @since 3.4
3432
*/
3533
class UnstructuredType extends AbstractType
3634
{
37-
/**
38-
* Configures the options for this type.
39-
*/
4035
public function configureOptions(OptionsResolver $resolver): void
4136
{
4237
$compoundNormalizer = fn() => false;

tests/BooleanToYesNoSubscriberTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public function testDataNotArray(): void
7878
$this->assertNull($form->get('isActive')->getData());
7979
}
8080

81+
/**
82+
* @return array<string, array{bool|null}>
83+
*/
8184
public function provider(): array
8285
{
8386
return [

0 commit comments

Comments
 (0)