Skip to content
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
8 changes: 0 additions & 8 deletions src/main/php/lang/ast/emit/php/XpMeta.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,4 @@ protected function emitMeta($result, $type, $annotations, $comment) {
protected function emitComment($result, $comment) {
// Omit from generated code
}

protected function emitAnnotation($result, $annotation) {
// Omit from generated code
}

protected function emitAnnotations($result, $annotations) {
// Omit from generated code
}
}
21 changes: 21 additions & 0 deletions src/test/php/lang/ast/unittest/emit/AnnotationsTest.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php namespace lang\ast\unittest\emit;

use ReflectionClass;
use lang\ast\emit\php\XpMeta;
use test\verify\Runtime;
use test\{Assert, Test, Values};

/**
* Annotations via XP Meta information
Expand All @@ -13,4 +16,22 @@ class AnnotationsTest extends AnnotationSupport {
/** @return string[] */
protected function emitters() { return [XpMeta::class]; }

/** @return iterable */
private function declarations() {
yield ['#[Test]', ['Test' => []]];
yield ['#[Test("a")]', ['Test' => ['a']]];
yield ['#[Test(1, 2, 3)]', ['Test' => [1, 2, 3]]];
yield ['#[Test(value: "a")]', ['Test' => ['value' => 'a']]];
}

#[Test, Runtime(php: '>=8.0.0-dev'), Values(from: 'declarations')]
public function also_emits_php_attributes($declaration, $expected) {
$type= $this->declare($declaration);
$declared= [];
foreach ((new ReflectionClass($type->literal()))->getAttributes() as $attribute) {
$declared[$attribute->getName()]= $attribute->getArguments();
}

Assert::equals($expected, $declared);
}
}
2 changes: 0 additions & 2 deletions src/test/php/lang/ast/unittest/emit/AttributesTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php namespace lang\ast\unittest\emit;

use lang\ast\emit\php\XpMeta;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unused import.


/**
* Annotations via PHP 8 attributes
*
Expand Down
Loading