Conditions | 3 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function resolve() :PropertyType{ |
||
32 | $type = new PropertyType(); |
||
33 | |||
34 | $docComment = $this->reflection->getDocComment(); |
||
35 | |||
36 | if (!$docComment) { |
||
37 | $type->setNullable(true); |
||
38 | |||
39 | return $type; |
||
40 | } |
||
41 | |||
42 | preg_match('/\@var ((?:(?:[\w|\\\\])+(?:\[\])?)+)/', $docComment, $matches); |
||
|
|||
43 | |||
44 | if (!count($matches)) { |
||
45 | $type->setNullable(true); |
||
46 | |||
47 | return $type; |
||
48 | } |
||
49 | |||
50 | $varDocComment = end($matches); |
||
51 | |||
52 | $type->setTypes($types = explode('|', $varDocComment)); |
||
53 | $type->setArrayTypes(str_replace('[]', '', $types)); |
||
54 | $type->setHasType(true); |
||
55 | $type->setNullable(strpos($varDocComment, 'null') !== false); |
||
56 | |||
57 | return $type; |
||
58 | } |
||
61 | } |