|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Spiral Framework package. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Spiral\Tests\Attributes\Concerns; |
|
13
|
|
|
|
|
14
|
|
|
use Spiral\Attributes\ReaderInterface; |
|
15
|
|
|
|
|
16
|
|
|
trait InteractWithMetadata |
|
17
|
|
|
{ |
|
18
|
|
|
use InteractWithReflection; |
|
19
|
|
|
|
|
20
|
|
|
abstract protected function getReader(): ReaderInterface; |
|
21
|
|
|
|
|
22
|
|
|
protected function getClassMetadata(string $class): iterable |
|
23
|
|
|
{ |
|
24
|
|
|
$reader = $this->getReader(); |
|
25
|
|
|
|
|
26
|
|
|
return $reader->getClassMetadata( |
|
27
|
|
|
$this->getReflectionClass($class) |
|
28
|
|
|
); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
protected function getMethodMetadata(string $class, string $name): iterable |
|
32
|
|
|
{ |
|
33
|
|
|
$reader = $this->getReader(); |
|
34
|
|
|
|
|
35
|
|
|
return $reader->getFunctionMetadata( |
|
36
|
|
|
$this->getReflectionMethod($class, $name) |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
protected function getFunctionMetadata(string $name): iterable |
|
41
|
|
|
{ |
|
42
|
|
|
$reader = $this->getReader(); |
|
43
|
|
|
|
|
44
|
|
|
return $reader->getFunctionMetadata( |
|
45
|
|
|
$this->getReflectionFunction($name) |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function getPropertyMetadata(string $class, string $name): iterable |
|
50
|
|
|
{ |
|
51
|
|
|
$reader = $this->getReader(); |
|
52
|
|
|
|
|
53
|
|
|
return $reader->getPropertyMetadata( |
|
54
|
|
|
$this->getReflectionProperty($class, $name) |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function getConstantMetadata(string $class, string $name): iterable |
|
59
|
|
|
{ |
|
60
|
|
|
$reader = $this->getReader(); |
|
61
|
|
|
|
|
62
|
|
|
return $reader->getConstantMetadata( |
|
63
|
|
|
$this->getReflectionConstant($class, $name) |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
protected function getFunctionParameterMetadata(string $function, string $name): iterable |
|
68
|
|
|
{ |
|
69
|
|
|
$reader = $this->getReader(); |
|
70
|
|
|
|
|
71
|
|
|
return $reader->getParameterMetadata( |
|
72
|
|
|
$this->getReflectionFunctionParameter($function, $name) |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
protected function getMethodParameterMetadata(string $class, string $method, string $name): iterable |
|
77
|
|
|
{ |
|
78
|
|
|
$reader = $this->getReader(); |
|
79
|
|
|
|
|
80
|
|
|
return $reader->getParameterMetadata( |
|
81
|
|
|
$this->getReflectionMethodParameter($class, $method, $name) |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|