1 | <?php |
||
13 | trait TraitsPart { |
||
14 | |||
15 | /** @var array */ |
||
16 | private $traits = []; |
||
17 | |||
18 | /** |
||
19 | * Adds a use statement with an optional alias |
||
20 | * |
||
21 | * @param string $qualifiedName |
||
22 | * @param null|string $alias |
||
23 | * @return $this |
||
24 | */ |
||
25 | abstract public function addUseStatement($qualifiedName, $alias = null); |
||
26 | |||
27 | /** |
||
28 | * Removes a use statement |
||
29 | * |
||
30 | * @param string $qualifiedName |
||
31 | * @return $this |
||
32 | */ |
||
33 | abstract public function removeUseStatement($qualifiedName); |
||
34 | |||
35 | /** |
||
36 | * Returns the namespace |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | abstract public function getNamespace(); |
||
41 | |||
42 | /** |
||
43 | * Adds a trait. |
||
44 | * |
||
45 | * If the trait is passed as PhpTrait object, |
||
46 | * the trait is also added as use statement. |
||
47 | * |
||
48 | * @param PhpTrait|string $trait trait or qualified name |
||
49 | * @return $this |
||
50 | */ |
||
51 | 5 | public function addTrait($trait) { |
|
70 | |||
71 | /** |
||
72 | * Returns a collection of traits |
||
73 | * |
||
74 | * @return string[] |
||
75 | */ |
||
76 | 13 | public function getTraits() { |
|
79 | |||
80 | /** |
||
81 | * Checks whether a trait exists |
||
82 | * |
||
83 | * @param PhpTrait|string $trait |
||
84 | * @return bool `true` if it exists and `false` if not |
||
85 | */ |
||
86 | 3 | public function hasTrait($trait) { |
|
93 | |||
94 | /** |
||
95 | * Removes a trait. |
||
96 | * |
||
97 | * If the trait is passed as PhpTrait object, |
||
98 | * the trait is also removed from use statements. |
||
99 | * |
||
100 | * @param PhpTrait|string $trait trait or qualified name |
||
101 | * @return $this |
||
102 | */ |
||
103 | 1 | public function removeTrait($trait) { |
|
122 | |||
123 | /** |
||
124 | * Sets a collection of traits |
||
125 | * |
||
126 | * @param PhpTrait[] $traits |
||
127 | * @return $this |
||
128 | */ |
||
129 | 1 | public function setTraits(array $traits) { |
|
136 | } |
||
137 |