Skip to content

Commit 62185ee

Browse files
committed
+ Support for namespaced annotations
1 parent 04c5f00 commit 62185ee

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

EComponentMeta.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function __construct(IAnnotated $component = null)
9797
foreach($properties as $property)
9898
{
9999
$name = $property->name;
100-
/* @var $property ReflectionProperty */
100+
/* @var $property ReflectionAnnotatedProperty */
101101
$field = new EComponentMetaProperty($property);
102102

103103
// Access options
@@ -116,7 +116,7 @@ protected function __construct(IAnnotated $component = null)
116116
}
117117
// Put it to metadata object
118118
$this->_fields[$field->name] = $field;
119-
119+
120120
foreach($property->getAllAnnotations() as $annotation)
121121
{
122122
if(!$annotation instanceof IComponentMetaAnnotation)

ReflectionAnnotatedProperty.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
class ReflectionAnnotatedProperty extends ReflectionProperty
44
{
5+
6+
/**
7+
*
8+
* @var EAnnotationsCollection
9+
*/
510
private $annotations;
611

712
public function __construct($class, $name)
@@ -36,8 +41,13 @@ public function getDeclaringClass()
3641
return new ReflectionAnnotatedClass($class->getName());
3742
}
3843

44+
/**
45+
* Create new annotations builder instance
46+
* @return \EAnnotationsBuilder
47+
*/
3948
protected function createAnnotationBuilder()
4049
{
4150
return new EAnnotationsBuilder();
4251
}
43-
}
52+
53+
}

builder/EAnnotationMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class EAnnotationMatcher extends ESerialMatcher
55
protected function build()
66
{
77
$this->add(new ERegexMatcher('@'));
8-
$this->add(new ERegexMatcher('[A-Z][a-zA-Z0-9_]*'));
8+
$this->add(new ERegexMatcher('[A-Z][a-zA-Z0-9_\\\]*'));
99
$this->add(new EAnnotationParametersMatcher);
1010
}
1111

builder/EAnnotationsBuilder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ public function instantiateAnnotation($class, $parameters, $targetReflection = f
3333
* and try to Yii::import('path.to.%class%Annotation');
3434
* OR better move this to EAddendum::resolveClassName
3535
*/
36-
$class = ucfirst($class) . "Annotation";
36+
if(strstr($class, '\\'))
37+
{
38+
// var_dump("Namespaced: $class");
39+
}
40+
else
41+
{
42+
$class = ucfirst($class) . "Annotation";
43+
}
3744
if(EAddendum::ignores($class))
3845
{
3946
return false;

0 commit comments

Comments
 (0)