@@ -21,6 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * PriorityQueue constructor. |
23 | 23 | * @param Factory[] ...$factories |
24 | + * @param ComplexTypeFactory $factories |
|
24 | 25 | */ |
25 | 26 | public function __construct(Factory ...$factories) |
26 | 27 | { |
@@ -38,8 +39,8 @@ discard block |
||
38 | 39 | } |
39 | 40 | |
40 | 41 | /** |
41 | - * @param mixed $value |
|
42 | - * @param mixed $priority |
|
42 | + * @param Factory $value |
|
43 | + * @param integer $priority |
|
43 | 44 | */ |
44 | 45 | public function insert($value, $priority) |
45 | 46 | { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -43,6 +43,6 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function insert($value, $priority) |
45 | 45 | { |
46 | - parent::insert($value, [$priority, $this->serial--]); |
|
46 | + parent::insert($value, [ $priority, $this->serial-- ]); |
|
47 | 47 | } |
48 | 48 | } |
@@ -8,8 +8,6 @@ |
||
8 | 8 | |
9 | 9 | namespace KleijnWeb\PhpApi\Hydrator\Processors\Object; |
10 | 10 | |
11 | -use KleijnWeb\PhpApi\Descriptions\Description\Schema\ObjectSchema; |
|
12 | - |
|
13 | 11 | /** |
14 | 12 | * @author John Kleijn <[email protected]> |
15 | 13 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | $object = $this->getObjectForHydration($input); |
25 | 25 | |
26 | 26 | foreach ($this->reflectionProperties as $name => $reflectionProperty) { |
27 | - if (isset($this->reflectionProperties[$name])) { |
|
27 | + if (isset($this->reflectionProperties[ $name ])) { |
|
28 | 28 | if (!property_exists($input, $name)) { |
29 | - if (!isset($this->defaults[$name])) { |
|
29 | + if (!isset($this->defaults[ $name ])) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | - $value = $this->defaults[$name]; |
|
32 | + $value = $this->defaults[ $name ]; |
|
33 | 33 | } else { |
34 | 34 | $value = $input->$name; |
35 | 35 | } |
36 | 36 | |
37 | - if (isset($this->propertyProcessors[$name])) { |
|
37 | + if (isset($this->propertyProcessors[ $name ])) { |
|
38 | 38 | $value = $this->hydrateProperty($name, $value); |
39 | 39 | } |
40 | - $this->reflectionProperties[$name]->setValue($object, $value); |
|
40 | + $this->reflectionProperties[ $name ]->setValue($object, $value); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @param mixed $node |
61 | - * @return mixed |
|
61 | + * @return \stdClass |
|
62 | 62 | */ |
63 | 63 | public function dehydrate($node) |
64 | 64 | { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $defaults = []; |
|
29 | + protected $defaults = [ ]; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * ObjectHydrator constructor. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | foreach ($schema->getPropertySchemas() as $name => $propertySchema) { |
44 | 44 | if (!null !== $default = $propertySchema->getDefault()) { |
45 | - $this->defaults[$name] = $default; |
|
45 | + $this->defaults[ $name ] = $default; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function setPropertyProcessor(string $key, Processor $child): ObjectProcessor |
73 | 73 | { |
74 | - $this->propertyProcessors[$key] = $child; |
|
74 | + $this->propertyProcessors[ $key ] = $child; |
|
75 | 75 | |
76 | 76 | return $this; |
77 | 77 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function hydrateProperty($key, $data) |
84 | 84 | { |
85 | - $next = $this->propertyProcessors[$key]; |
|
85 | + $next = $this->propertyProcessors[ $key ]; |
|
86 | 86 | |
87 | 87 | return $next->hydrate($data); |
88 | 88 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function dehydrateProperty($key, $data) |
95 | 95 | { |
96 | - $next = $this->propertyProcessors[$key]; |
|
96 | + $next = $this->propertyProcessors[ $key ]; |
|
97 | 97 | |
98 | 98 | return $next->dehydrate($data); |
99 | 99 | } |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * Cast a scalar value using the schema. |
31 | 31 | * |
32 | 32 | * @param mixed $value |
33 | - * @param Schema $schema |
|
34 | 33 | * |
35 | 34 | * @return float|int|string|\DateTimeInterface |
36 | 35 | * @throws UnsupportedException |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @var array |
20 | 20 | */ |
21 | - protected $resourceNamespaces = []; |
|
21 | + protected $resourceNamespaces = [ ]; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @var array |
25 | 25 | */ |
26 | - protected $cache = []; |
|
26 | + protected $cache = [ ]; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * ClassNameResolver constructor. |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function resolve(string $typeName): string |
44 | 44 | { |
45 | - if (!isset($this->cache[$typeName])) { |
|
45 | + if (!isset($this->cache[ $typeName ])) { |
|
46 | 46 | foreach ($this->resourceNamespaces as $resourceNamespace) { |
47 | - if (class_exists($this->cache[$typeName] = $this->qualify($resourceNamespace, $typeName))) { |
|
48 | - return $this->cache[$typeName]; |
|
47 | + if (class_exists($this->cache[ $typeName ] = $this->qualify($resourceNamespace, $typeName))) { |
|
48 | + return $this->cache[ $typeName ]; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | - return $this->cache[$typeName]; |
|
61 | + return $this->cache[ $typeName ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct(string ...$formats) |
43 | 43 | { |
44 | - if (isset($formats[0])) { |
|
45 | - $this->outputFormat = $formats[0]; |
|
44 | + if (isset($formats[ 0 ])) { |
|
45 | + $this->outputFormat = $formats[ 0 ]; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $this->inputDateTimeFormats = $formats + $this->inputDateTimeFormats; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function hydrateObject(\stdClass $input) |
24 | 24 | { |
25 | - $object = (object)[]; |
|
25 | + $object = (object)[ ]; |
|
26 | 26 | |
27 | 27 | /** @var ObjectSchema $objectSchema */ |
28 | 28 | $objectSchema = $this->schema; |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @var Schema $propertySchema |
33 | 33 | */ |
34 | 34 | foreach ($objectSchema->getPropertySchemas() as $name => $propertySchema) { |
35 | - if (!isset($input->$name) && isset($this->defaults[$name])) { |
|
36 | - $value = $this->defaults[$name]; |
|
35 | + if (!isset($input->$name) && isset($this->defaults[ $name ])) { |
|
36 | + $value = $this->defaults[ $name ]; |
|
37 | 37 | } else { |
38 | 38 | $value = $input->$name; |
39 | 39 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function dehydrateObject($object): \stdClass |
51 | 51 | { |
52 | - $node = (object)[]; |
|
52 | + $node = (object)[ ]; |
|
53 | 53 | /** @var ObjectSchema $objectSchema */ |
54 | 54 | $objectSchema = $this->schema; |
55 | 55 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function hydrateObject(\stdClass $input) |
41 | 41 | { |
42 | - $output = (object)[]; |
|
42 | + $output = (object)[ ]; |
|
43 | 43 | |
44 | 44 | /** @var ObjectSchema $objectSchema */ |
45 | 45 | $objectSchema = $this->schema; |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | /** @var Schema $propertySchema */ |
48 | 48 | foreach ($objectSchema->getPropertySchemas() as $name => $propertySchema) { |
49 | 49 | if (!property_exists($input, $name)) { |
50 | - if (!isset($this->defaults[$name])) { |
|
50 | + if (!isset($this->defaults[ $name ])) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | - $value = $this->defaults[$name]; |
|
53 | + $value = $this->defaults[ $name ]; |
|
54 | 54 | } else { |
55 | 55 | $value = $input->$name; |
56 | 56 | } |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | $objectSchema = $this->schema; |
77 | 77 | |
78 | 78 | /** @var Schema[] $propertySchemas */ |
79 | - $propertySchemas = []; |
|
79 | + $propertySchemas = [ ]; |
|
80 | 80 | |
81 | 81 | $output = clone $input; |
82 | 82 | |
83 | 83 | foreach ($input as $name => $value) { |
84 | 84 | if ($objectSchema->hasPropertySchema($name)) { |
85 | - $propertySchemas[$name] = $objectSchema->getPropertySchema($name); |
|
85 | + $propertySchemas[ $name ] = $objectSchema->getPropertySchema($name); |
|
86 | 86 | } else { |
87 | 87 | $output->$name = $this->anyProcessor->dehydrate($value); |
88 | 88 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /* |
3 | 3 | * This file is part of the KleijnWeb\PhpApi\Hydrator package. |
4 | 4 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @var \ReflectionProperty[] |
25 | 25 | */ |
26 | - protected $reflectionProperties = []; |
|
26 | + protected $reflectionProperties = [ ]; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @var string |
@@ -38,27 +38,27 @@ discard block |
||
38 | 38 | |
39 | 39 | foreach ($this->reflector->getProperties() as $reflectionProperty) { |
40 | 40 | $reflectionProperty->setAccessible(true); |
41 | - $this->reflectionProperties[$reflectionProperty->getName()] = $reflectionProperty; |
|
41 | + $this->reflectionProperties[ $reflectionProperty->getName() ] = $reflectionProperty; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | protected function dehydrateObject($object): \stdClass |
47 | 47 | { |
48 | - $node = (object)[]; |
|
48 | + $node = (object)[ ]; |
|
49 | 49 | |
50 | 50 | /** @var ObjectSchema $objectSchema */ |
51 | 51 | $objectSchema = $this->schema; |
52 | 52 | |
53 | 53 | foreach ($objectSchema->getPropertySchemas() as $name => $propertySchema) { |
54 | - if (!isset($this->reflectionProperties[$name])) { |
|
55 | - if (!isset($this->defaults[$name])) { |
|
54 | + if (!isset($this->reflectionProperties[ $name ])) { |
|
55 | + if (!isset($this->defaults[ $name ])) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | - $value = $this->defaults[$name]; |
|
58 | + $value = $this->defaults[ $name ]; |
|
59 | 59 | } |
60 | 60 | else { |
61 | - $value = $this->reflectionProperties[$name]->getValue($object); |
|
61 | + $value = $this->reflectionProperties[ $name ]->getValue($object); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | if ($this->shouldFilterOutputValue($objectSchema->getPropertySchema($name), $value)) { |
@@ -56,8 +56,7 @@ |
||
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | $value = $this->defaults[$name]; |
59 | - } |
|
60 | - else { |
|
59 | + } else { |
|
61 | 60 | $value = $this->reflectionProperties[$name]->getValue($object); |
62 | 61 | } |
63 | 62 |