Skip to content

Commit

Permalink
Deprecate XP annotation syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 18, 2021
1 parent 5eefd09 commit e828a43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/php/lang/reflect/ClassParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public function parseAnnotations($bytes, $context, $imports= [], $line= -1) {
$value= null;
$i++;
$state= 1;
trigger_error('XP annotation syntax is deprecated in '.$context, E_USER_DEPRECATED);
} else if (T_STRING === $tokens[$i][0]) {
$annotation= lcfirst($tokens[$i][1]);
$param= null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ class AnnotationParsingTest extends AbstractAnnotationParsingTest {
* @return [:var]
*/
protected function parse($input, $imports= []) {
return (new ClassParser())->parseAnnotations($input, nameof($this), array_merge($imports, [
'Namespaced' => 'net.xp_framework.unittest.annotations.fixture.Namespaced'
]));
try {
return (new ClassParser())->parseAnnotations($input, nameof($this), array_merge($imports, [
'Namespaced' => 'net.xp_framework.unittest.annotations.fixture.Namespaced'
]));
} finally {
\xp::gc(); // Strip deprecation warning
}
}

#[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ class BrokenAnnotationTest extends TestCase {
* @return [:var]
*/
protected function parse($input) {
return (new ClassParser())->parseAnnotations($input, nameof($this));
try {
return (new ClassParser())->parseAnnotations($input, nameof($this));
} finally {
\xp::gc(); // Strip deprecation warning
}
}

#[Test, Action(eval: 'new RuntimeVersion("<8.0")'), Expect(['class' => ClassFormatException::class, 'withMessage' => '/Unterminated annotation/'])]
Expand Down

0 comments on commit e828a43

Please sign in to comment.