@@ -12,13 +12,20 @@ final class Hydrator implements HydratorInterface
12
12
{
13
13
14
14
public const NO_STRICT_KEYS = 0b00000001 ;
15
- public const IGNORE_KEYS = 0b00000010 ;
16
- public const DEFAULT = 0b00000000 ;
15
+ public const IGNORE_KEYS = 0b00000010 ;
16
+ public const DEFAULT = 0b00000000 ;
17
17
18
+ /**
19
+ * @param callable $callback
20
+ * @param object $entity
21
+ * @param mixed ...$args
22
+ *
23
+ * @return mixed
24
+ */
18
25
private function invoke (callable $ callback , object $ entity , ...$ args )
19
26
{
20
27
if ($ callback instanceof \Closure) {
21
- $ callback = $ callback ->bindTo ($ entity , $ entity );
28
+ $ callback = $ callback ->bindTo ($ entity , $ entity ) ?: $ callback ;
22
29
}
23
30
24
31
return call_user_func_array ($ callback , $ args );
@@ -33,7 +40,7 @@ public function hydrate(
33
40
$ hydratorProperties = $ config ->getHydratorProperties ();
34
41
35
42
if ($ flags & static ::IGNORE_KEYS ) {
36
- $ data = array_combine (array_keys ($ hydratorProperties ),$ data );
43
+ $ data = array_combine (array_keys ($ hydratorProperties ), $ data );
37
44
}
38
45
39
46
if (~$ flags & static ::NO_STRICT_KEYS ) {
@@ -54,6 +61,7 @@ public function extract(ExtractorConfigInterface $config, object $entity): array
54
61
$ data = [];
55
62
56
63
foreach ($ config ->getExtractorProperties () as $ propertyName => $ get ) {
64
+ /** @psalm-suppress MixedAssignment */
57
65
$ data [$ propertyName ] = $ this ->invoke ($ get , $ entity , $ propertyName );
58
66
}
59
67
0 commit comments