Skip to content

Commit b6e119d

Browse files
committed
bug-fixed: parse full namespace in relationship
1 parent 659fd14 commit b6e119d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ParseTypeScript/Parser.php

Lines changed: 4 additions & 3 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-\\\\]+)"/i', $docComment, $matches)) {
155155
$result = $this->getRelationCollectionProperty($docComment);
156156
}
157157
}
@@ -223,13 +223,14 @@ private function getRelationCollectionProperty(string $type): string
223223
$matches = [];
224224

225225
$regex = array(
226-
'/OneToOne\(targetEntity="([a-zA-Z]+)"/i' => '',
226+
'/targetEntity="([a-zA-Z]+)"/i' => '',
227+
'/targetEntity="([a-zA-Z]+)\\\\([a-zA-Z]+)\\\\([a-zA-Z]+)"/i' => '',
227228
'/targetEntity="([a-zA-Z]+)"/i' => '[]',
228229
);
229230

230231
foreach ($regex as $reg => $val) {
231232
if (preg_match($reg, $type, $matches)) {
232-
$result = $matches[1] . $val;
233+
$result = end($matches) . $val;
233234
break;
234235
}
235236
}

0 commit comments

Comments
 (0)