@@ -122,9 +122,13 @@ public function setExtends(string $extends): self
122
122
return $ this ;
123
123
}
124
124
125
- public function setImplements (string ...$ interfaces ): self
125
+ public function setImplements (string ...$ implements ): self
126
126
{
127
- $ this ->implements = $ interfaces ;
127
+ $ this ->implements = [];
128
+
129
+ foreach ($ implements as $ implement ) {
130
+ $ this ->implements [$ implement ] = $ implement ;
131
+ }
128
132
129
133
return $ this ;
130
134
}
@@ -144,6 +148,11 @@ public function addImplement(string ...$implements): self
144
148
return $ this ;
145
149
}
146
150
151
+ public function hasImplement (string $ implement ): bool
152
+ {
153
+ return isset ($ this ->implements [$ implement ]);
154
+ }
155
+
147
156
public function setNamespace (string $ namespace ): self
148
157
{
149
158
$ this ->namespace = $ namespace ;
@@ -198,6 +207,11 @@ public function removeNamespaceImport(string ...$namespaceImports): self
198
207
return $ this ;
199
208
}
200
209
210
+ public function hasNamespaceImport (string $ namespace ): bool
211
+ {
212
+ return isset ($ this ->namespaceImports [$ namespace ]);
213
+ }
214
+
201
215
/**
202
216
* @deprecated Use setNamespaceImports()
203
217
* @param string ...$namespaces
@@ -255,6 +269,11 @@ public function removeTrait(string ...$traits): self
255
269
return $ this ;
256
270
}
257
271
272
+ public function hasTrait (string $ trait ): bool
273
+ {
274
+ return isset ($ this ->traits [$ trait ]);
275
+ }
276
+
258
277
/**
259
278
* @deprecated Use setTraits()
260
279
* @param string ...$traits
@@ -273,7 +292,11 @@ public function setUseTrait(string ...$traits): self
273
292
*/
274
293
public function setConstants (ClassConstBuilder ...$ constants ): self
275
294
{
276
- $ this ->constants = $ constants ;
295
+ $ this ->constants = [];
296
+
297
+ foreach ($ constants as $ constant ) {
298
+ $ this ->constants [$ constant ->getName ()] = $ constant ;
299
+ }
277
300
278
301
return $ this ;
279
302
}
@@ -308,6 +331,11 @@ public function removeConstant(string ...$constants): self
308
331
return $ this ;
309
332
}
310
333
334
+ public function hasConstant (string $ constantName ): bool
335
+ {
336
+ return isset ($ this ->constants [$ constantName ]);
337
+ }
338
+
311
339
/**
312
340
* Replacing will not work on existing files
313
341
*
@@ -355,6 +383,11 @@ public function removeProperty(string ...$propertyNames): self
355
383
return $ this ;
356
384
}
357
385
386
+ public function hasProperty (string $ propertyName ): bool
387
+ {
388
+ return isset ($ this ->properties [$ propertyName ]);
389
+ }
390
+
358
391
public function setMethods (ClassMethodBuilder ...$ methods ): self
359
392
{
360
393
$ this ->methods = [];
@@ -396,6 +429,11 @@ public function removeMethod(string ...$methodNames): self
396
429
return $ this ;
397
430
}
398
431
432
+ public function hasMethod (string $ methodName ): bool
433
+ {
434
+ return isset ($ this ->methods [$ methodName ]);
435
+ }
436
+
399
437
public function getNamespace (): ?string
400
438
{
401
439
return $ this ->namespace ;
0 commit comments