Skip to content

Commit 61c09ea

Browse files
committed
feature #119 add property type hints (xabbuh)
This PR was merged into the 0.2-dev branch. Discussion ---------- add property type hints Commits ------- f1f1c21 add property type hints
2 parents 24a6e34 + f1f1c21 commit 61c09ea

12 files changed

+45
-38
lines changed

src/Qossmic/DataMapper/DataMapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
*/
2929
class DataMapper implements DataMapperInterface
3030
{
31-
private $dataMapper;
32-
private $propertyAccessor;
33-
private $formExceptionHandler;
31+
private DataMapperInterface $dataMapper;
32+
private PropertyAccessorInterface $propertyAccessor;
33+
private FormExceptionHandler $formExceptionHandler;
3434

3535
public function __construct(DataMapperInterface $dataMapper, PropertyAccessorInterface $propertyAccessor, FormExceptionHandler $formExceptionHandler)
3636
{

src/Qossmic/DataTransformer/ValueObjectTransformer.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class ValueObjectTransformer implements DataTransformerInterface
3030
{
3131
use ExceptionToErrorMapperTrait;
3232

33-
private $propertyAccessor;
34-
private $form;
33+
private PropertyAccessorInterface $propertyAccessor;
34+
private FormBuilderInterface $form;
3535

3636
public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry, PropertyAccessorInterface $propertyAccessor, FormBuilderInterface $form)
3737
{
@@ -43,7 +43,7 @@ public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry,
4343
/**
4444
* @param mixed $value
4545
*
46-
* @return string|array<string,string>|null
46+
* @return array<string,bool|int|string|null>|bool|int|string|null
4747
*/
4848
public function transform($value)
4949
{
@@ -73,10 +73,7 @@ public function transform($value)
7373
return $this->getPropertyValue($this->form, $value);
7474
}
7575

76-
/**
77-
* @return object
78-
*/
79-
public function reverseTransform($value)
76+
public function reverseTransform($value): object
8077
{
8178
try {
8279
return (new ViewDataInstantiator($this->form, $value))->instantiateObject();
@@ -92,11 +89,9 @@ public function reverseTransform($value)
9289
}
9390

9491
/**
95-
* @param object $object
96-
*
97-
* @return string
92+
* @return bool|int|string|null
9893
*/
99-
private function getPropertyValue(FormBuilderInterface $form, $object)
94+
private function getPropertyValue(FormBuilderInterface $form, object $object)
10095
{
10196
if (null !== $form->getPropertyPath()) {
10297
return $this->propertyAccessor->getValue($object, $form->getPropertyPath());

src/Qossmic/ExceptionHandling/ChainExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
class ChainExceptionHandler implements ExceptionHandlerInterface
3333
{
34-
private $exceptionHandlers;
34+
private iterable $exceptionHandlers;
3535

3636
/**
3737
* @param ExceptionHandlerInterface[] $exceptionHandlers

src/Qossmic/ExceptionHandling/Error.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*/
2222
class Error
2323
{
24-
private $cause;
25-
private $messageTemplate;
26-
private $parameters;
24+
private \Throwable $cause;
25+
private string $messageTemplate;
26+
private array $parameters;
2727

2828
public function __construct(\Throwable $cause, string $messageTemplate, array $parameters = [])
2929
{

src/Qossmic/ExceptionHandling/ExceptionHandlerRegistry.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
*/
2222
class ExceptionHandlerRegistry
2323
{
24-
private $container;
25-
private $strategies;
24+
private ContainerInterface $container;
25+
/** @var array<string,string> */
26+
private array $strategies;
2627

28+
/**
29+
* @param array<string,string> $strategies
30+
*/
2731
public function __construct(ContainerInterface $container, array $strategies)
2832
{
2933
$this->container = $container;

src/Qossmic/ExceptionHandling/ExceptionToErrorMapperTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
trait ExceptionToErrorMapperTrait
2525
{
26-
private $exceptionHandlerRegistry;
26+
private ExceptionHandlerRegistry $exceptionHandlerRegistry;
2727

2828
/**
2929
* @param mixed $data

src/Qossmic/ExceptionHandling/FormExceptionHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class FormExceptionHandler
2525
{
2626
use ExceptionToErrorMapperTrait;
2727

28-
private $translator;
29-
private $translationDomain;
28+
private ?TranslatorInterface $translator;
29+
private ?string $translationDomain;
3030

3131
public function __construct(ExceptionHandlerRegistry $exceptionHandlerRegistry, TranslatorInterface $translator = null, string $translationDomain = null)
3232
{

src/Qossmic/ExceptionHandling/GenericExceptionHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
*/
3333
class GenericExceptionHandler implements ExceptionHandlerInterface
3434
{
35-
private $handledExceptionClass;
35+
/** @var class-string */
36+
private string $handledExceptionClass;
3637

38+
/**
39+
* @param class-string $handledExceptionClass
40+
*/
3741
public function __construct(string $handledExceptionClass)
3842
{
3943
$this->handledExceptionClass = $handledExceptionClass;

src/Qossmic/Extension/RichModelFormsTypeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
*/
3737
class RichModelFormsTypeExtension extends AbstractTypeExtension
3838
{
39-
private $propertyAccessor;
40-
private $exceptionHandlerRegistry;
41-
private $formExceptionHandler;
39+
private PropertyAccessorInterface $propertyAccessor;
40+
private ExceptionHandlerRegistry $exceptionHandlerRegistry;
41+
private FormExceptionHandler $formExceptionHandler;
4242

4343
public function __construct(PropertyAccessorInterface $propertyAccessor, ExceptionHandlerRegistry $exceptionHandlerRegistry, FormExceptionHandler $formExceptionHandler)
4444
{

src/Qossmic/Instantiator/FormDataInstantiator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
*/
2222
class FormDataInstantiator extends ObjectInstantiator
2323
{
24-
private $form;
25-
private $formNameForArgument;
24+
private FormInterface $form;
25+
/** @var array<string,string> */
26+
private array $formNameForArgument;
2627

2728
/**
2829
* @param class-string|\Closure|(callable&array) $factory
@@ -34,7 +35,7 @@ public function __construct($factory, FormInterface $form)
3435
$this->form = $form;
3536
$this->formNameForArgument = [];
3637

37-
foreach ($form as $name => $child) {
38+
foreach ($form as $child) {
3839
$this->formNameForArgument[$child->getConfig()->getOption('factory_argument') ?? $child->getName()] = $child->getName();
3940
}
4041
}

0 commit comments

Comments
 (0)