Skip to content

Commit 9866245

Browse files
authored
Merge pull request #4 from SebLevDev/SebLevDev-patch-1
Update EntityToPropertyTransformer.php
2 parents 9df123d + f49af18 commit 9866245

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

Form/DataTransformer/EntityToPropertyTransformer.php

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,18 @@
1010

1111
/**
1212
* Data transformer for single mode (i.e., multiple = false)
13-
*
14-
* Class EntityToPropertyTransformer
15-
*
16-
* @package Tetranz\Select2EntityBundle\Form\DataTransformer
1713
*/
1814
class EntityToPropertyTransformer implements DataTransformerInterface
1915
{
20-
/** @var ObjectManager */
21-
protected $em;
22-
/** @var string */
23-
protected $className;
24-
/** @var string */
25-
protected $textProperty;
26-
/** @var string */
27-
protected $primaryKey;
28-
/** @var string */
29-
protected $newTagPrefix;
30-
/** @var string */
31-
protected $newTagText;
32-
/** @var PropertyAccessor */
33-
protected $accessor;
16+
protected ObjectManager $em;
17+
protected string $className;
18+
protected ?string $textProperty;
19+
protected string $primaryKey;
20+
protected string $newTagPrefix;
21+
protected string $newTagText;
22+
protected PropertyAccessor $accessor;
3423

35-
/**
36-
* @param ObjectManager $em
37-
* @param string $class
38-
* @param string|null $textProperty
39-
* @param string $primaryKey
40-
* @param string $newTagPrefix
41-
*/
42-
public function __construct(ObjectManager $em, $class, $textProperty = null, $primaryKey = 'id', $newTagPrefix = '__', $newTagText = ' (NEW)')
24+
public function __construct(ObjectManager $em, string $class, ?string $textProperty = null, string $primaryKey = 'id', string $newTagPrefix = '__', string $newTagText = ' (NEW)')
4325
{
4426
$this->em = $em;
4527
$this->className = $class;
@@ -52,11 +34,8 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr
5234

5335
/**
5436
* Transform entity to array
55-
*
56-
* @param mixed $entity
57-
* @return array
5837
*/
59-
public function transform($entity)
38+
public function transform(mixed $value): mixed
6039
{
6140
$data = array();
6241
if (empty($entity)) {
@@ -81,11 +60,8 @@ public function transform($entity)
8160

8261
/**
8362
* Transform single id value to an entity
84-
*
85-
* @param string $value
86-
* @return mixed|null|object
8763
*/
88-
public function reverseTransform($value)
64+
public function reverseTransform(mixed $value): mixed
8965
{
9066
if (empty($value)) {
9167
return null;

0 commit comments

Comments
 (0)