3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
9 namespace Zend\Code\Generator
;
11 interface TraitUsageInterface
14 * Add a class to "use" classes
17 * @param string|null $useAlias
20 public function addUse($use, $useAlias = null);
23 * Returns the "use" classes
27 public function getUses();
30 * Add trait takes an array of trait options or string as arguments.
33 * key: traitName value: String
35 * key: aliases value: array of arrays
36 * key: method value: @see addTraitAlias
37 * key: alias value: @see addTraitAlias
38 * key: visibility value: @see addTraitAlias
40 * key: insteadof value: array of arrays
41 * key: method value: @see self::addTraitOverride
42 * key: traitToReplace value: @see self::addTraitOverride
44 * @param mixed $trait String | Array
47 public function addTrait($trait);
50 * Add multiple traits. Trait can be an array of trait names or array of trait
53 * @param array $traitName Array of string names or configurations (@see addTrait)
56 public function addTraits(array $traits);
59 * Check to see if the class has a trait defined
61 * @param strint $traitName
64 public function hasTrait($traitName);
67 * Get a list of trait names
71 public function getTraits();
74 * Remove a trait by its name
78 public function removeTrait($traitName);
81 * Add a trait alias. This will be used to generate the AS portion of the use statement.
84 * This method provides 2 ways for defining the trait method.
87 * key: traitName value: name of trait
88 * key: method value: trait method
91 * Alias is a string representing the new method name.
94 * ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PRIVATE| ReflectionMethod::IS_PROTECTED
96 * @param mixed $method String or Array
97 * @param string $alias
98 * @param int $visiblity
100 public function addTraitAlias($method, $alias, $visibility = null);
105 public function getTraitAliases();
108 * Add a trait method override. This will be used to generate the INSTEADOF portion of the use
112 * This method provides 2 ways for defining the trait method.
113 * Option 1: String Format: <trait name>::<method name>
115 * key: traitName value: trait name
116 * key: method value: method name
119 * The name of the trait that you wish to supersede.
121 * This method provides 2 ways for defining the trait method.
122 * Option 1: String of trait to replace
123 * Option 2: Array of strings of traits to replace
125 * @param mixed $method
126 * @param mixed $traitToReplace
128 public function addTraitOverride($method, $traitsToReplace);
131 * Remove an override for a given trait::method
134 * This method provides 2 ways for defining the trait method.
135 * Option 1: String Format: <trait name>::<method name>
137 * key: traitName value: trait name
138 * key: method value: method name
140 * $overridesToRemove:
141 * The name of the trait that you wish to remove.
143 * This method provides 2 ways for defining the trait method.
144 * Option 1: String of trait to replace
145 * Option 2: Array of strings of traits to replace
147 * @param $traitAndMethod
148 * @param null $overridesToRemove
151 public function removeTraitOverride($method, $overridesToRemove = null);
154 * Return trait overrides
158 public function getTraitOverrides();