Skip to content

Commit

Permalink
Merge pull request #334 from thekid/fix/original-attribute-names
Browse files Browse the repository at this point in the history
Store original attribute names in DETAIL_TARGET_ANNO
  • Loading branch information
thekid authored Jul 22, 2023
2 parents 5877fcf + e7afd6c commit b114f3a
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 65 deletions.
12 changes: 8 additions & 4 deletions src/main/php/lang/reflect/ClassParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public function parseAnnotations($bytes, $context, $imports= [], $line= -1) {
} else {
$type= $this->type($tokens, $i, $context, $imports);
$annotation= lcfirst(false === ($p= strrpos($type, '.')) ? $type : substr($type, $p + 1));
$annotations[1][$annotation]= $type;
$param= null;
$value= null;
$state= 1;
Expand Down Expand Up @@ -582,7 +583,8 @@ public function parseDetails($bytes) {
4, // "/**\n"
strpos($comment, '* @')- 2 // position of first details token
))),
DETAIL_ANNOTATIONS => $annotations[0]
DETAIL_ANNOTATIONS => $annotations[0],
DETAIL_TARGET_ANNO => $annotations[1]
];
$annotations= [0 => [], 1 => []];
$comment= '';
Expand All @@ -599,7 +601,7 @@ public function parseDetails($bytes) {
$parsed= '';
}
$f= substr($tokens[$i][1], 1);
$details[0][$f]= [DETAIL_ANNOTATIONS => $annotations[0]];
$details[0][$f]= [DETAIL_ANNOTATIONS => $annotations[0], DETAIL_TARGET_ANNO => $annotations[1]];
$annotations= [0 => [], 1 => []];
$matches= null;
if ('' === $comment) break;
Expand Down Expand Up @@ -673,12 +675,14 @@ public function parseDetails($bytes) {
}
}
} else if (T_VARIABLE === $tokens[$i][0] && null !== $parsed) {
$details[1][$m][DETAIL_TARGET_ANNO][$tokens[$i][1]]= $this->parseAnnotations(
$annotations= $this->parseAnnotations(
$parsed,
$context,
$imports,
$tokens[$i][2] ?? -1
)[0];
);
$details[1][$m][DETAIL_TARGET_ANNO][$tokens[$i][1]]= $annotations[0];
$details[1][$m][DETAIL_TARGET_ANNO]+= $annotations[1];
$parsed= null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/unittest/AnnotationParsingTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function multi_line_annotation() {
'lang.unittest.SecondInterceptor',
]]], 1 => []],
$this->parse("
#[Interceptors(['classes' => [
#[@interceptors(['classes' => [
'lang.unittest.FirstInterceptor',
'lang.unittest.SecondInterceptor',
]])]
Expand Down
Loading

0 comments on commit b114f3a

Please sign in to comment.