@@ -96,10 +96,11 @@ public function getClassName(): string
9696
9797 public function implements (string ...$ interfaces ): self
9898 {
99- foreach ($ interfaces as $ interface ) {
99+ foreach ($ interfaces as & $ interface ) {
100100 if (!interface_exists ($ interface )) {
101101 throw ReflectionApiException::forNonExistentInterface ($ interface );
102102 }
103+ $ interface = '\\' . $ interface ;
103104 }
104105 $ this ->implements = $ interfaces ;
105106
@@ -111,17 +112,18 @@ public function extends(string $class): self
111112 if (!class_exists ($ class )) {
112113 throw ReflectionApiException::forNonExistentClass ($ class );
113114 }
114- $ this ->extends = $ class ;
115+ $ this ->extends = '\\' . $ class ;
115116
116117 return $ this ;
117118 }
118119
119120 public function use (string ...$ traits ): self
120121 {
121- foreach ($ traits as $ trait ) {
122+ foreach ($ traits as & $ trait ) {
122123 if (!trait_exists ($ trait )) {
123124 throw ReflectionApiException::forNonExistentTrait ($ trait );
124125 }
126+ $ trait = '\\' . $ trait ;
125127 }
126128 $ this ->uses = $ traits ;
127129
@@ -130,22 +132,17 @@ public function use(string ...$traits): self
130132
131133 public function isUsing (string $ name ): bool
132134 {
133- return in_array ($ name , $ this ->uses );
134- }
135-
136- public function isImplementing (string $ name ): bool
137- {
138- return in_array ($ name , $ this ->implements );
135+ return in_array ('\\' . $ name , $ this ->uses );
139136 }
140137
141138 public function isExtending (string $ name ): bool
142139 {
143- return $ name === $ this ->extends ;
140+ return ( '\\' . $ name) === $ this ->extends ;
144141 }
145142
146143 public function implementsInterface (string $ interface ): bool
147144 {
148- return in_array ($ interface , $ this ->implements );
145+ return in_array ('\\' . $ interface , $ this ->implements );
149146 }
150147
151148 public function addMethod (RuntimeMethod $ method ): self
0 commit comments