14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+ declare (strict_types=1 );
18
+
17
19
namespace gossi \codegen \model ;
18
20
19
21
use gossi \codegen \model \parts \DocblockPart ;
@@ -50,7 +52,7 @@ abstract class AbstractPhpStruct extends AbstractModel implements NamespaceInter
50
52
* @param string $name the fqcn
51
53
* @return static
52
54
*/
53
- public static function create ($ name = null ) {
55
+ public static function create (? string $ name = null ) {
54
56
return new static ($ name );
55
57
}
56
58
@@ -59,7 +61,7 @@ public static function create($name = null) {
59
61
*
60
62
* @param string $name the fqcn
61
63
*/
62
- public function __construct ($ name = null ) {
64
+ public function __construct (? string $ name = null ) {
63
65
$ this ->setQualifiedName ($ name );
64
66
$ this ->docblock = new Docblock ();
65
67
$ this ->useStatements = new Map ();
@@ -85,7 +87,7 @@ public function setRequiredFiles(array $files) {
85
87
* @param string $file
86
88
* @return $this
87
89
*/
88
- public function addRequiredFile ($ file ) {
90
+ public function addRequiredFile (string $ file ) {
89
91
$ this ->requiredFiles ->add ($ file );
90
92
91
93
return $ this ;
@@ -96,7 +98,7 @@ public function addRequiredFile($file) {
96
98
*
97
99
* @return Set collection of filenames
98
100
*/
99
- public function getRequiredFiles () {
101
+ public function getRequiredFiles (): Set {
100
102
return $ this ->requiredFiles ;
101
103
}
102
104
@@ -124,7 +126,7 @@ public function setUseStatements(array $useStatements) {
124
126
* @param null|string $alias
125
127
* @return $this
126
128
*/
127
- public function addUseStatement ($ qualifiedName , $ alias = null ) {
129
+ public function addUseStatement (string $ qualifiedName , string $ alias = null ) {
128
130
if (!is_string ($ alias )) {
129
131
if (false === strpos ($ qualifiedName , '\\' )) {
130
132
$ alias = $ qualifiedName ;
@@ -137,15 +139,15 @@ public function addUseStatement($qualifiedName, $alias = null) {
137
139
138
140
return $ this ;
139
141
}
140
-
142
+
141
143
/**
142
144
* Clears all use statements
143
- *
145
+ *
144
146
* @return $this
145
147
*/
146
148
public function clearUseStatements () {
147
149
$ this ->useStatements ->clear ();
148
-
150
+
149
151
return $ this ;
150
152
}
151
153
@@ -155,8 +157,8 @@ public function clearUseStatements() {
155
157
* @param ... use statements multiple qualified names
156
158
* @return $this
157
159
*/
158
- public function declareUses () {
159
- foreach (func_get_args () as $ name ) {
160
+ public function declareUses (string ... $ uses ) {
161
+ foreach ($ uses as $ name ) {
160
162
$ this ->declareUse ($ name );
161
163
}
162
164
return $ this ;
@@ -173,7 +175,7 @@ public function declareUses() {
173
175
* @param null|string $alias
174
176
* @return string the used alias
175
177
*/
176
- public function declareUse ($ qualifiedName , $ alias = null ) {
178
+ public function declareUse (string $ qualifiedName , string $ alias = null ) {
177
179
$ qualifiedName = trim ($ qualifiedName , '\\' );
178
180
if (!$ this ->hasUseStatement ($ qualifiedName )) {
179
181
$ this ->addUseStatement ($ qualifiedName , $ alias );
@@ -187,7 +189,7 @@ public function declareUse($qualifiedName, $alias = null) {
187
189
* @param string $qualifiedName
188
190
* @return bool
189
191
*/
190
- public function hasUseStatement ($ qualifiedName ) {
192
+ public function hasUseStatement (string $ qualifiedName ): bool {
191
193
return $ this ->useStatements ->contains ($ qualifiedName );
192
194
}
193
195
@@ -197,7 +199,7 @@ public function hasUseStatement($qualifiedName) {
197
199
* @param string $qualifiedName
198
200
* @return string the alias
199
201
*/
200
- public function getUseAlias ($ qualifiedName ) {
202
+ public function getUseAlias (string $ qualifiedName ): string {
201
203
return $ this ->useStatements ->getKey ($ qualifiedName );
202
204
}
203
205
@@ -207,7 +209,7 @@ public function getUseAlias($qualifiedName) {
207
209
* @param string $qualifiedName
208
210
* @return $this
209
211
*/
210
- public function removeUseStatement ($ qualifiedName ) {
212
+ public function removeUseStatement (string $ qualifiedName ) {
211
213
$ this ->useStatements ->remove ($ this ->useStatements ->getKey ($ qualifiedName ));
212
214
return $ this ;
213
215
}
@@ -217,7 +219,7 @@ public function removeUseStatement($qualifiedName) {
217
219
*
218
220
* @return Map collection of use statements
219
221
*/
220
- public function getUseStatements () {
222
+ public function getUseStatements (): Map {
221
223
return $ this ->useStatements ;
222
224
}
223
225
@@ -281,7 +283,7 @@ public function removeMethod($nameOrMethod) {
281
283
* @param string|PhpMethod $nameOrMethod method name or Method instance
282
284
* @return bool `true` if it exists and `false` if not
283
285
*/
284
- public function hasMethod ($ nameOrMethod ) {
286
+ public function hasMethod ($ nameOrMethod ): bool {
285
287
if ($ nameOrMethod instanceof PhpMethod) {
286
288
$ nameOrMethod = $ nameOrMethod ->getName ();
287
289
}
@@ -296,7 +298,7 @@ public function hasMethod($nameOrMethod) {
296
298
* @throws \InvalidArgumentException if the method cannot be found
297
299
* @return PhpMethod
298
300
*/
299
- public function getMethod ($ nameOrMethod ) {
301
+ public function getMethod ($ nameOrMethod ): PhpMethod {
300
302
if ($ nameOrMethod instanceof PhpMethod) {
301
303
$ nameOrMethod = $ nameOrMethod ->getName ();
302
304
}
@@ -313,7 +315,7 @@ public function getMethod($nameOrMethod) {
313
315
*
314
316
* @return Map collection of methods
315
317
*/
316
- public function getMethods () {
318
+ public function getMethods (): Map {
317
319
return $ this ->methods ;
318
320
}
319
321
@@ -322,7 +324,7 @@ public function getMethods() {
322
324
*
323
325
* @return Set
324
326
*/
325
- public function getMethodNames () {
327
+ public function getMethodNames (): Set {
326
328
return $ this ->methods ->keys ();
327
329
}
328
330
0 commit comments