Skip to content

Commit a366857

Browse files
committed
ParseTypeScript/Parser.php bug-fixed en las relaciones y el nuevo modo de definición de doctrine, para las targetEntity
1 parent aca9d24 commit a366857

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ParseTypeScript/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private function parsePhpDocForProperty(\ReflectionProperty $property): string
151151
if ($result === 'unknown') {
152152
if (preg_match('/type="([a-zA-Z]+)"/i', $docComment, $matches)) {
153153
$result = $this->getTypescriptProperty($matches[1]);
154-
} elseif (preg_match('/targetEntity="([a-zA-Z-\\\\]+)"/i', $docComment, $matches)) {
154+
} elseif (preg_match('/targetEntity=("[a-zA-Z-\\\\]+")|([a-zA-Z]+::class)/i', $docComment, $matches)) {
155155
$result = $this->getRelationCollectionProperty($docComment);
156156
}
157157
}
@@ -226,14 +226,15 @@ private function getRelationCollectionProperty(string $type): string
226226

227227
$regex = array(
228228
'/targetEntity="([a-zA-Z]+)"/i',
229+
'/targetEntity=([a-zA-Z]+)::class/i',
229230
'/targetEntity="([a-zA-Z]+)\\\\([a-zA-Z]+)\\\\([a-zA-Z]+)"/i',
230231
);
231232

232233
foreach ($regex as $reg) {
233234
if (preg_match($reg, $type, $matches)) {
234235

235236
$collection = '[]';
236-
if (strpos($type, 'OneToOne') !== false) {
237+
if (strpos($type, 'OneToOne') !== false || strpos($type, 'ManyToOne') !== false) {
237238
$collection = '';
238239
}
239240

0 commit comments

Comments
 (0)