Skip to content

Commit 3a7450a

Browse files
committed
fix issues reported by PhpStan
1 parent e121444 commit 3a7450a

File tree

8 files changed

+28
-3
lines changed

8 files changed

+28
-3
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
'import_functions' => false,
4949
],
5050
'modernize_strpos' => false,
51+
'no_superfluous_phpdoc_tags' => false,
5152
'ordered_imports' => true,
5253
'php_unit_no_expectation_annotation' => false,
5354
'void_return' => true,

src/Qossmic/DataMapper/PropertyMapperInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020
*/
2121
interface PropertyMapperInterface
2222
{
23+
/**
24+
* @param mixed $data
25+
*
26+
* @return mixed
27+
*/
2328
public function readPropertyValue($data);
2429

30+
/**
31+
* @param mixed $data
32+
* @param mixed $value
33+
*/
2534
public function writePropertyValue($data, $value): void;
2635
}

src/Qossmic/DependencyInjection/Compiler/RegisterExceptionHandlersPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function process(ContainerBuilder $container): void
3939
$strategies = [];
4040

4141
foreach ($container->findTaggedServiceIds('qossmic.rich_model_forms.exception_handler') as $id => $tag) {
42+
/** @var class-string $class */
4243
$class = $container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass());
4344
$exceptionHandlers[$id] = new TypedReference($id, $class);
4445

src/Qossmic/ExceptionHandling/ExceptionHandlerInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
*/
3333
interface ExceptionHandlerInterface
3434
{
35+
/**
36+
* @param mixed $data
37+
*/
3538
public function getError(FormConfigInterface $formConfig, $data, \Throwable $e): ?Error;
3639
}

src/Qossmic/ExceptionHandling/ExceptionToErrorMapperTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ trait ExceptionToErrorMapperTrait
2626
{
2727
private ExceptionHandlerRegistry $exceptionHandlerRegistry;
2828

29+
/**
30+
* @param mixed $data
31+
*/
2932
private function mapExceptionToError(FormConfigInterface $formConfig, $data, \Throwable $e): ?Error
3033
{
3134
$exceptionHandlers = [];

src/Qossmic/ExceptionHandling/FormExceptionHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry,
3636
$this->translationDomain = $translationDomain;
3737
}
3838

39+
/**
40+
* @param mixed $data
41+
*/
3942
public function handleException(FormInterface $form, $data, \Throwable $e): void
4043
{
4144
if (null !== $error = $this->mapExceptionToError($form->getConfig(), $data, $e)) {

src/Qossmic/Instantiator/ObjectInstantiator.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class ObjectInstantiator
2525
private $factory;
2626

2727
/**
28-
* @param class-string|\Closure|(callable&array) $factory
28+
* @param mixed $factory
2929
*/
3030
public function __construct($factory)
3131
{
@@ -34,7 +34,7 @@ public function __construct($factory)
3434

3535
public function instantiateObject(): ?object
3636
{
37-
if (\is_string($this->factory)) {
37+
if (\is_string($this->factory) && class_exists($this->factory)) {
3838
$factoryMethod = (new \ReflectionClass($this->factory))->getConstructor();
3939

4040
if (null === $factoryMethod) {
@@ -78,7 +78,13 @@ public function instantiateObject(): ?object
7878

7979
abstract protected function isCompoundForm(): bool;
8080

81+
/**
82+
* @return mixed
83+
*/
8184
abstract protected function getData();
8285

86+
/**
87+
* @return mixed
88+
*/
8389
abstract protected function getArgumentData(string $argument);
8490
}

src/Qossmic/Instantiator/ViewDataInstantiator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ViewDataInstantiator extends ObjectInstantiator
3333
*/
3434
public function __construct(FormBuilderInterface $form, $viewData)
3535
{
36-
/* @phpstan-ignore-next-line */
3736
parent::__construct($form->getFormConfig()->getOption('factory'));
3837

3938
$this->form = $form;

0 commit comments

Comments
 (0)