File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1313use PHPStan \PhpDocParser \Ast \Type \ArrayTypeNode ;
1414use PHPStan \PhpDocParser \Ast \Type \GenericTypeNode ;
1515use PHPStan \PhpDocParser \Ast \Type \IdentifierTypeNode ;
16+ use PHPStan \PhpDocParser \Ast \Type \NullableTypeNode ;
1617use PHPStan \PhpDocParser \Ast \Type \TypeNode ;
1718use PHPStan \PhpDocParser \Ast \Type \UnionTypeNode ;
1819use PHPStan \PhpDocParser \Lexer \Lexer ;
2223use PHPStan \PhpDocParser \Parser \TypeParser ;
2324use Riverwaysoft \PhpConverter \Dto \DtoClassProperty ;
2425use Riverwaysoft \PhpConverter \Dto \PhpType \PhpListType ;
26+ use Riverwaysoft \PhpConverter \Dto \PhpType \PhpOptionalType ;
2527use Riverwaysoft \PhpConverter \Dto \PhpType \PhpTypeFactory ;
2628use Riverwaysoft \PhpConverter \Dto \PhpType \PhpTypeInterface ;
2729use Riverwaysoft \PhpConverter \Dto \PhpType \PhpUnionType ;
@@ -144,6 +146,9 @@ private function convertToDto(TypeNode $node): PhpTypeInterface|null
144146 if ($ node instanceof UnionTypeNode) {
145147 return new PhpUnionType (array_map (fn (TypeNode $ child ) => $ this ->convertToDto ($ child ), $ node ->types ));
146148 }
149+ if ($ node instanceof NullableTypeNode) {
150+ return new PhpOptionalType ($ this ->convertToDto ($ node ->type ));
151+ }
147152 if ($ node instanceof GenericTypeNode) {
148153 return PhpTypeFactory::create ($ node ->type ->name , array_map (
149154 fn (TypeNode $ child ) => $ this ->convertToDto ($ child ),
Original file line number Diff line number Diff line change 1010use Riverwaysoft \PhpConverter \Dto \DtoClassProperty ;
1111use Riverwaysoft \PhpConverter \Dto \PhpType \PhpBaseType ;
1212use Riverwaysoft \PhpConverter \Dto \PhpType \PhpListType ;
13+ use Riverwaysoft \PhpConverter \Dto \PhpType \PhpOptionalType ;
1314use Riverwaysoft \PhpConverter \Dto \PhpType \PhpTypeInterface ;
1415use Riverwaysoft \PhpConverter \Dto \PhpType \PhpUnionType ;
1516use Riverwaysoft \PhpConverter \Dto \PhpType \PhpUnknownType ;
@@ -112,6 +113,15 @@ public static function getDataVarAndReturn(): array
112113 PhpBaseType::null (),
113114 ]),
114115 ],
116+ [
117+ 'nullable optional string array ' ,
118+ '/** @var ?string[] */ ' ,
119+ new PhpOptionalType (
120+ new PhpListType (
121+ PhpBaseType::string (),
122+ ),
123+ ),
124+ ],
115125 [
116126 '2d array ' ,
117127 '/** @var int[][] */ ' ,
You can’t perform that action at this time.
0 commit comments