Skip to content

Commit 7537de6

Browse files
committed
minor #122 use PhpStan 1.x (xabbuh)
This PR was merged into the 0.2-dev branch. Discussion ---------- use PhpStan 1.x Commits ------- 6bd4524 use PhpStan 1.x
2 parents a3aee78 + 6bd4524 commit 7537de6

File tree

10 files changed

+20
-2
lines changed

10 files changed

+20
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require-dev": {
2929
"friendsofphp/php-cs-fixer": "^3.4",
30-
"phpstan/phpstan": "^0.12.4",
30+
"phpstan/phpstan": "^1.7.11",
3131
"symfony/phpunit-bridge": "^4.4.12||^5.4",
3232
"symfony/translation": "^4.4||^5.4||^6.0"
3333
},

src/Qossmic/DataMapper/DataMapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public function mapDataToForms($data, $forms): void
6161
if (!$isDataEmpty && $readPropertyPath instanceof \Closure && $form->getConfig()->getMapped()) {
6262
$form->setData($readPropertyPath($data));
6363
} elseif (!$isDataEmpty && null !== $readPropertyPath && $form->getConfig()->getMapped()) {
64+
/* @phpstan-ignore-next-line */
6465
$form->setData($this->propertyAccessor->getValue($data, $readPropertyPath));
6566
} elseif (!$isDataEmpty && null !== $propertyMapper) {
67+
/* @phpstan-ignore-next-line */
6668
$form->setData($propertyMapper->readPropertyValue($data));
6769
} elseif (null !== $readPropertyPath) {
6870
$form->setData($form->getConfig()->getData());
@@ -102,8 +104,10 @@ public function mapFormsToData($forms, &$data): void
102104
if ($readPropertyPath instanceof \Closure) {
103105
$previousValue = $readPropertyPath($data);
104106
} elseif (null !== $readPropertyPath) {
107+
/* @phpstan-ignore-next-line */
105108
$previousValue = $this->propertyAccessor->getValue($data, $readPropertyPath);
106109
} elseif (null !== $propertyMapper) {
110+
/* @phpstan-ignore-next-line */
107111
$previousValue = $propertyMapper->readPropertyValue($data);
108112
} else {
109113
$previousValue = null;

src/Qossmic/DataTransformer/ValueObjectTransformer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry,
4141
}
4242

4343
/**
44-
* @param mixed $value
44+
* @param object|null $value
4545
*
4646
* @return array<string,bool|int|string|null>|bool|int|string|null
4747
*/
@@ -76,6 +76,7 @@ public function transform($value)
7676
public function reverseTransform($value): ?object
7777
{
7878
try {
79+
/* @phpstan-ignore-next-line */
7980
return (new ViewDataInstantiator($this->form, $value))->instantiateObject();
8081
} catch (\Throwable $e) {
8182
$error = $this->mapExceptionToError($this->form, $value, $e);
@@ -94,6 +95,7 @@ public function reverseTransform($value): ?object
9495
private function getPropertyValue(FormBuilderInterface $form, object $object)
9596
{
9697
if (null !== $form->getPropertyPath()) {
98+
/* @phpstan-ignore-next-line */
9799
return $this->propertyAccessor->getValue($object, $form->getPropertyPath());
98100
}
99101

@@ -103,6 +105,7 @@ private function getPropertyValue(FormBuilderInterface $form, object $object)
103105
return $readPropertyPath($object);
104106
}
105107

108+
/* @phpstan-ignore-next-line */
106109
return $this->propertyAccessor->getValue($object, $readPropertyPath);
107110
}
108111
}

src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function get(string $strategy): ExceptionHandlerInterface
4545
throw new \InvalidArgumentException(sprintf('The exception handling strategy "%s" is not registered (use one of ["%s"]).', $strategy, implode(', ', array_keys($this->strategies))));
4646
}
4747

48+
/* @phpstan-ignore-next-line */
4849
return $this->container->get($this->strategies[$strategy]);
4950
}
5051
}

src/Qossmic/ExceptionHandling/ExceptionToErrorMapperTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ private function mapExceptionToError(FormConfigInterface $formConfig, $data, \Th
3333
$exceptionHandlers = [];
3434

3535
if (null !== $formConfig->getOption('handle_exception')) {
36+
/* @phpstan-ignore-next-line */
3637
foreach ($formConfig->getOption('handle_exception') as $exceptionClass) {
38+
/* @phpstan-ignore-next-line */
3739
$exceptionHandlers[] = new GenericExceptionHandler($exceptionClass);
3840
}
3941

4042
$exceptionHandlers[] = $this->exceptionHandlerRegistry->get('type_error');
4143
} else {
44+
/* @phpstan-ignore-next-line */
4245
foreach ($formConfig->getOption('exception_handling_strategy') as $strategy) {
46+
/* @phpstan-ignore-next-line */
4347
$exceptionHandlers[] = $this->exceptionHandlerRegistry->get($strategy);
4448
}
4549
}

src/Qossmic/ExceptionHandling/FallbackExceptionHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function getError(FormConfigInterface $formConfig, $data, \Throwable $e):
3838
$messageTemplate = $formConfig->getOption('invalid_message') ?? 'This value is not valid.';
3939
$parameters = $formConfig->getOption('invalid_message_parameters') ?? [];
4040

41+
/* @phpstan-ignore-next-line */
4142
return new Error($e, $messageTemplate, $parameters);
4243
}
4344
}

src/Qossmic/Extension/RichModelFormsTypeExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public function configureOptions(OptionsResolver $resolver): void
177177
}
178178

179179
try {
180+
/* @phpstan-ignore-next-line */
180181
return (new FormDataInstantiator($options['factory'], $form))->instantiateObject();
181182
} catch (\Throwable $e) {
182183
$this->formExceptionHandler->handleException($form, $form->getData(), $e);

src/Qossmic/Instantiator/FormDataInstantiator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct($factory, FormInterface $form)
3636
$this->formNameForArgument = [];
3737

3838
foreach ($form as $child) {
39+
/* @phpstan-ignore-next-line */
3940
$this->formNameForArgument[$child->getConfig()->getOption('factory_argument') ?? $child->getName()] = $child->getName();
4041
}
4142
}

src/Qossmic/Instantiator/ObjectInstantiator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function instantiateObject(): ?object
5454
} elseif ($this->factory instanceof \Closure) {
5555
$factoryMethod = new \ReflectionFunction($this->factory);
5656
} else {
57+
/* @phpstan-ignore-next-line */
5758
return $this->getData();
5859
}
5960

src/Qossmic/Instantiator/ViewDataInstantiator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ class ViewDataInstantiator extends ObjectInstantiator
3232
*/
3333
public function __construct(FormBuilderInterface $form, $viewData)
3434
{
35+
/* @phpstan-ignore-next-line */
3536
parent::__construct($form->getFormConfig()->getOption('factory'));
3637

3738
$this->form = $form;
3839
$this->viewData = $viewData;
3940
$this->formNameForArgument = [];
4041

4142
foreach ($form as $child) {
43+
/* @phpstan-ignore-next-line */
4244
$this->formNameForArgument[$child->getOption('factory_argument') ?? $child->getName()] = $child->getName();
4345
}
4446
}

0 commit comments

Comments
 (0)