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