Skip to content

Commit

Permalink
bug-fixed: parse full namespace in relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
ddniel16 committed Mar 9, 2020
1 parent 659fd14 commit b6e119d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ParseTypeScript/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private function parsePhpDocForProperty(\ReflectionProperty $property): string
if ($result === 'unknown') {
if (preg_match('/type="([a-zA-Z]+)"/i', $docComment, $matches)) {
$result = $this->getTypescriptProperty($matches[1]);
} elseif (preg_match('/targetEntity="([a-zA-Z]+)"/i', $docComment, $matches)) {
} elseif (preg_match('/targetEntity="([a-zA-Z-\\\\]+)"/i', $docComment, $matches)) {
$result = $this->getRelationCollectionProperty($docComment);
}
}
Expand Down Expand Up @@ -223,13 +223,14 @@ private function getRelationCollectionProperty(string $type): string
$matches = [];

$regex = array(
'/OneToOne\(targetEntity="([a-zA-Z]+)"/i' => '',
'/targetEntity="([a-zA-Z]+)"/i' => '',
'/targetEntity="([a-zA-Z]+)\\\\([a-zA-Z]+)\\\\([a-zA-Z]+)"/i' => '',
'/targetEntity="([a-zA-Z]+)"/i' => '[]',
);

foreach ($regex as $reg => $val) {
if (preg_match($reg, $type, $matches)) {
$result = $matches[1] . $val;
$result = end($matches) . $val;
break;
}
}
Expand Down

0 comments on commit b6e119d

Please sign in to comment.