-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAnnotations.php
60 lines (50 loc) · 1.65 KB
/
testAnnotations.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Created by IntelliJ IDEA.
* User: manuel
* Date: 05/12/2016
* Time: 00:14
*/
require_once "com/annotations/core/classes/class.annotationsfetcher.inc";
require_once "com/annotations/core/classes/annotations/class.classannotation.inc";
require_once "com/annotations/core/classes/annotations/class.methodannotation.inc";
require_once "com/annotations/core/classes/annotations/class.paramannotation.inc";
/**
* @Annotation Class {type=interface}
*/
interface TestA {
public function sayHello();
}
/**
* @Annotation Class {type=trait}
*/
trait TestB{
/**
* @Annotation Method {name = sayHello, visibility = public}
*/
public function sayHello(){
echo "Hello World";
}
}
/**
* @Annotation Class {type=class}
*/
class TestC implements TestA{
use TestB;
/**
* @Annotation Param {name=test, type=string, lengthMax=25, default=prova}
*/
private $test = "prova";
}
$fetcher = new AnnotationsFetcher();
$annotationsTestA = $fetcher->getAnnotationsForClass("TestA");
$annotationsMethodSayHello = $fetcher->getAnnotationsForMethod("TestB", "sayHello");
$annotationsPropertyTest = $fetcher->getAnnotationsFroProperty("TestC", "test");
$objAnn = $annotationsTestA[0];
var_dump($objAnn);
echo "Class Annotation => " . $objAnn->__get("type") . " " . $objAnn->getName() . " " . $objAnn->getVisibility() . "\n";
$objAnn = $annotationsMethodSayHello[0];
echo "Method Annotation => " . $objAnn->getName() . " " . $objAnn->getVisibility() . "\n";
$objAnn = $annotationsPropertyTest[0];
var_dump($objAnn);
echo "Param Annotation => " . $objAnn->getName() . " " . $objAnn->getLengthMax() . " " . $objAnn->getDefault() . "\n";