@@ -122,9 +122,13 @@ public function setExtends(string $extends): self
122122 return $ this ;
123123 }
124124
125- public function setImplements (string ...$ interfaces ): self
125+ public function setImplements (string ...$ implements ): self
126126 {
127- $ this ->implements = $ interfaces ;
127+ $ this ->implements = [];
128+
129+ foreach ($ implements as $ implement ) {
130+ $ this ->implements [$ implement ] = $ implement ;
131+ }
128132
129133 return $ this ;
130134 }
@@ -144,6 +148,11 @@ public function addImplement(string ...$implements): self
144148 return $ this ;
145149 }
146150
151+ public function hasImplement (string $ implement ): bool
152+ {
153+ return isset ($ this ->implements [$ implement ]);
154+ }
155+
147156 public function setNamespace (string $ namespace ): self
148157 {
149158 $ this ->namespace = $ namespace ;
@@ -198,6 +207,11 @@ public function removeNamespaceImport(string ...$namespaceImports): self
198207 return $ this ;
199208 }
200209
210+ public function hasNamespaceImport (string $ namespace ): bool
211+ {
212+ return isset ($ this ->namespaceImports [$ namespace ]);
213+ }
214+
201215 /**
202216 * @deprecated Use setNamespaceImports()
203217 * @param string ...$namespaces
@@ -255,6 +269,11 @@ public function removeTrait(string ...$traits): self
255269 return $ this ;
256270 }
257271
272+ public function hasTrait (string $ trait ): bool
273+ {
274+ return isset ($ this ->traits [$ trait ]);
275+ }
276+
258277 /**
259278 * @deprecated Use setTraits()
260279 * @param string ...$traits
@@ -273,7 +292,11 @@ public function setUseTrait(string ...$traits): self
273292 */
274293 public function setConstants (ClassConstBuilder ...$ constants ): self
275294 {
276- $ this ->constants = $ constants ;
295+ $ this ->constants = [];
296+
297+ foreach ($ constants as $ constant ) {
298+ $ this ->constants [$ constant ->getName ()] = $ constant ;
299+ }
277300
278301 return $ this ;
279302 }
@@ -308,6 +331,11 @@ public function removeConstant(string ...$constants): self
308331 return $ this ;
309332 }
310333
334+ public function hasConstant (string $ constantName ): bool
335+ {
336+ return isset ($ this ->constants [$ constantName ]);
337+ }
338+
311339 /**
312340 * Replacing will not work on existing files
313341 *
@@ -355,6 +383,11 @@ public function removeProperty(string ...$propertyNames): self
355383 return $ this ;
356384 }
357385
386+ public function hasProperty (string $ propertyName ): bool
387+ {
388+ return isset ($ this ->properties [$ propertyName ]);
389+ }
390+
358391 public function setMethods (ClassMethodBuilder ...$ methods ): self
359392 {
360393 $ this ->methods = [];
@@ -396,6 +429,11 @@ public function removeMethod(string ...$methodNames): self
396429 return $ this ;
397430 }
398431
432+ public function hasMethod (string $ methodName ): bool
433+ {
434+ return isset ($ this ->methods [$ methodName ]);
435+ }
436+
399437 public function getNamespace (): ?string
400438 {
401439 return $ this ->namespace ;
0 commit comments