Skip to content

Commit

Permalink
fix issues reported by PhpStan
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 27, 2023
1 parent e121444 commit 3a7450a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'import_functions' => false,
],
'modernize_strpos' => false,
'no_superfluous_phpdoc_tags' => false,
'ordered_imports' => true,
'php_unit_no_expectation_annotation' => false,
'void_return' => true,
Expand Down
9 changes: 9 additions & 0 deletions src/Qossmic/DataMapper/PropertyMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@
*/
interface PropertyMapperInterface
{
/**
* @param mixed $data
*
* @return mixed
*/
public function readPropertyValue($data);

/**
* @param mixed $data
* @param mixed $value
*/
public function writePropertyValue($data, $value): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function process(ContainerBuilder $container): void
$strategies = [];

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

Expand Down
3 changes: 3 additions & 0 deletions src/Qossmic/ExceptionHandling/ExceptionHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
*/
interface ExceptionHandlerInterface
{
/**
* @param mixed $data
*/
public function getError(FormConfigInterface $formConfig, $data, \Throwable $e): ?Error;
}
3 changes: 3 additions & 0 deletions src/Qossmic/ExceptionHandling/ExceptionToErrorMapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ trait ExceptionToErrorMapperTrait
{
private ExceptionHandlerRegistry $exceptionHandlerRegistry;

/**
* @param mixed $data
*/
private function mapExceptionToError(FormConfigInterface $formConfig, $data, \Throwable $e): ?Error
{
$exceptionHandlers = [];
Expand Down
3 changes: 3 additions & 0 deletions src/Qossmic/ExceptionHandling/FormExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry,
$this->translationDomain = $translationDomain;
}

/**
* @param mixed $data
*/
public function handleException(FormInterface $form, $data, \Throwable $e): void
{
if (null !== $error = $this->mapExceptionToError($form->getConfig(), $data, $e)) {
Expand Down
10 changes: 8 additions & 2 deletions src/Qossmic/Instantiator/ObjectInstantiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class ObjectInstantiator
private $factory;

/**
* @param class-string|\Closure|(callable&array) $factory
* @param mixed $factory
*/
public function __construct($factory)
{
Expand All @@ -34,7 +34,7 @@ public function __construct($factory)

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

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

abstract protected function isCompoundForm(): bool;

/**
* @return mixed
*/
abstract protected function getData();

/**
* @return mixed
*/
abstract protected function getArgumentData(string $argument);
}
1 change: 0 additions & 1 deletion src/Qossmic/Instantiator/ViewDataInstantiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class ViewDataInstantiator extends ObjectInstantiator
*/
public function __construct(FormBuilderInterface $form, $viewData)
{
/* @phpstan-ignore-next-line */
parent::__construct($form->getFormConfig()->getOption('factory'));

$this->form = $form;
Expand Down

0 comments on commit 3a7450a

Please sign in to comment.