1 | <?php |
||
15 | trait TraitsPart { |
||
16 | |||
17 | /** @var string[] */ |
||
18 | private $traits = []; |
||
19 | |||
20 | /** |
||
21 | * Adds a use statement with an optional alias |
||
22 | * |
||
23 | * @param string $qualifiedName |
||
24 | * @param null|string $alias |
||
25 | * @return $this |
||
26 | */ |
||
27 | abstract public function addUseStatement($qualifiedName, string $alias = null); |
||
28 | |||
29 | /** |
||
30 | * Removes a use statement |
||
31 | * |
||
32 | * @param string $qualifiedName |
||
33 | * @return $this |
||
34 | */ |
||
35 | abstract public function removeUseStatement(string $qualifiedName); |
||
36 | |||
37 | /** |
||
38 | * Returns the namespace |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | abstract public function getNamespace(): ?string; |
||
43 | |||
44 | /** |
||
45 | * Adds a trait. |
||
46 | * |
||
47 | * If the trait is passed as PhpTrait object, |
||
48 | * the trait is also added as use statement. |
||
49 | * |
||
50 | * @param PhpTrait|string $trait trait or qualified name |
||
51 | * @return $this |
||
52 | */ |
||
53 | 4 | public function addTrait($trait) { |
|
68 | |||
69 | /** |
||
70 | * Returns a collection of traits |
||
71 | * |
||
72 | * @return string[] |
||
73 | */ |
||
74 | 15 | public function getTraits(): array { |
|
77 | |||
78 | /** |
||
79 | * @return iterable|PhpTrait[] |
||
80 | */ |
||
81 | public function getPhpTraits(): iterable { |
||
90 | |||
91 | /** |
||
92 | * Checks whether a trait exists |
||
93 | * |
||
94 | * @param PhpTrait|string $trait |
||
95 | * @return bool `true` if it exists and `false` if not |
||
96 | */ |
||
97 | 2 | public function hasTrait($trait): bool { |
|
104 | |||
105 | /** |
||
106 | * Removes a trait. |
||
107 | * |
||
108 | * If the trait is passed as PhpTrait object, |
||
109 | * the trait is also removed from use statements. |
||
110 | * |
||
111 | * @param PhpTrait|string $trait trait or qualified name |
||
112 | * @return $this |
||
113 | */ |
||
114 | 1 | public function removeTrait($trait) { |
|
133 | |||
134 | /** |
||
135 | * Sets a collection of traits |
||
136 | * |
||
137 | * @param PhpTrait[] $traits |
||
138 | * @return $this |
||
139 | */ |
||
140 | 1 | public function setTraits(array $traits) { |
|
147 | } |
||
148 |