Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store original attribute names in DETAIL_TARGET_ANNO #334

Merged
merged 4 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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