1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Vitaly Iegorov <[email protected]>. |
4
|
|
|
* on 07.08.16 at 13:32 |
5
|
|
|
*/ |
6
|
|
|
namespace samsonframework\container\resolver; |
7
|
|
|
|
8
|
|
|
use samsonframework\container\metadata\ClassMetadata; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Annotation resolver implementation. |
12
|
|
|
* |
13
|
|
|
* @package samsonframework\container\resolver |
14
|
|
|
*/ |
15
|
|
|
class AnnotationResolver implements Resolver |
16
|
|
|
{ |
17
|
|
|
/** @var AnnotationResolverInterface */ |
18
|
|
|
protected $classResolver; |
19
|
|
|
|
20
|
|
|
/** @var AnnotationResolverInterface */ |
21
|
|
|
protected $propertyResolver; |
22
|
|
|
|
23
|
|
|
/** @var AnnotationResolverInterface */ |
24
|
|
|
protected $methodResolver; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* AnnotationResolver constructor. |
28
|
|
|
* |
29
|
|
|
* @param AnnotationResolverInterface $classResolver |
30
|
|
|
* @param AnnotationResolverInterface $propertyResolver |
31
|
|
|
* @param AnnotationResolverInterface $methodResolver |
32
|
|
|
*/ |
33
|
1 |
|
public function __construct(AnnotationResolverInterface $classResolver, AnnotationResolverInterface $propertyResolver, AnnotationResolverInterface $methodResolver) |
34
|
|
|
{ |
35
|
1 |
|
$this->classResolver = $classResolver; |
36
|
1 |
|
$this->propertyResolver = $propertyResolver; |
37
|
1 |
|
$this->methodResolver = $methodResolver; |
38
|
1 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
*/ |
43
|
1 |
|
public function resolve($classData, $identifier = null) |
44
|
|
|
{ |
45
|
|
|
/** @var \ReflectionClass $classData */ |
46
|
|
|
|
47
|
|
|
// Create and fill class metadata base fields |
48
|
1 |
|
$classMetadata = new ClassMetadata(); |
49
|
|
|
|
50
|
|
|
// Resolve class definition annotations |
51
|
1 |
|
$this->classResolver->resolve($classData, $classMetadata); |
52
|
|
|
// Resolve class properties annotations |
53
|
1 |
|
$this->propertyResolver->resolve($classData, $classMetadata); |
54
|
|
|
// Resolve class methods annotations |
55
|
1 |
|
$this->methodResolver->resolve($classData, $classMetadata); |
56
|
|
|
|
57
|
1 |
|
return $classMetadata; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|