1 | <?php |
||
22 | final class DateTimeTypeAdapter extends TypeAdapter |
||
23 | { |
||
24 | /** |
||
25 | * @var PhpType |
||
26 | */ |
||
27 | private $phpType; |
||
28 | |||
29 | /** |
||
30 | * Constructor |
||
31 | * |
||
32 | * @param PhpType $phpType |
||
33 | */ |
||
34 | 8 | public function __construct(PhpType $phpType) |
|
38 | |||
39 | /** |
||
40 | * Read the next value, convert it to its type and return it |
||
41 | * |
||
42 | * @param JsonReadable $reader |
||
43 | * @return DateTime|null |
||
|
|||
44 | * @throws \OutOfRangeException if the key doesn't exist |
||
45 | */ |
||
46 | 5 | public function read(JsonReadable $reader): ?DateTime |
|
69 | |||
70 | /** |
||
71 | * Write the value to the writer for the type |
||
72 | * |
||
73 | * @param JsonWritable $writer |
||
74 | * @param DateTime $value |
||
75 | * @return void |
||
76 | */ |
||
77 | 3 | public function write(JsonWritable $writer, $value): void |
|
94 | } |
||
95 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.