|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Railt package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Railt\Reflection\Dictionary; |
|
11
|
|
|
|
|
12
|
|
|
use Railt\Reflection\Contracts\Definition; |
|
13
|
|
|
use Railt\Reflection\Contracts\Definition\TypeDefinition; |
|
14
|
|
|
use Railt\Reflection\Contracts\Dictionary; |
|
15
|
|
|
use Railt\Reflection\Contracts\Type; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class ProxyDictionary |
|
19
|
|
|
*/ |
|
20
|
|
|
class ProxyDictionary implements Dictionary |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var Dictionary |
|
24
|
|
|
*/ |
|
25
|
|
|
private $parent; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* ProxyDictionary constructor. |
|
29
|
|
|
* @param Dictionary $parent |
|
30
|
|
|
*/ |
|
31
|
9 |
|
public function __construct(Dictionary $parent) |
|
32
|
|
|
{ |
|
33
|
9 |
|
$this->parent = $parent; |
|
34
|
9 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param Type|null $of |
|
38
|
|
|
* @return iterable|TypeDefinition[] |
|
39
|
|
|
*/ |
|
40
|
3 |
|
public function all(Type $of = null): iterable |
|
41
|
|
|
{ |
|
42
|
3 |
|
yield from $this->parent->all($of); |
|
43
|
3 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $name |
|
47
|
|
|
* @return bool |
|
48
|
|
|
*/ |
|
49
|
3 |
|
public function has(string $name): bool |
|
50
|
|
|
{ |
|
51
|
3 |
|
return $this->parent->has($name); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $name |
|
56
|
|
|
* @return null|TypeDefinition |
|
57
|
|
|
*/ |
|
58
|
5 |
|
public function find(string $name): ?TypeDefinition |
|
59
|
|
|
{ |
|
60
|
5 |
|
return $this->parent->find($name); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $name |
|
65
|
|
|
* @param Definition|null $from |
|
66
|
|
|
* @return TypeDefinition |
|
67
|
|
|
* @throws \Railt\Reflection\Exception\TypeNotFoundException |
|
68
|
|
|
*/ |
|
69
|
3 |
|
public function get(string $name, Definition $from = null): TypeDefinition |
|
70
|
|
|
{ |
|
71
|
3 |
|
return $this->parent->get($name, $from); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param TypeDefinition $type |
|
76
|
|
|
* @return Dictionary |
|
77
|
|
|
*/ |
|
78
|
5 |
|
public function add(TypeDefinition $type): Dictionary |
|
79
|
|
|
{ |
|
80
|
5 |
|
return $this->parent->add($type); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|