File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,17 @@ public function addNamespace(string|PhpNamespace $namespace): PhpNamespace
110
110
}
111
111
112
112
113
+ /**
114
+ * Removes the namespace from the file.
115
+ */
116
+ public function removeNamespace (string |PhpNamespace $ namespace ): static
117
+ {
118
+ $ name = $ namespace instanceof PhpNamespace ? $ namespace ->getName () : $ namespace ;
119
+ unset($ this ->namespaces [$ name ]);
120
+ return $ this ;
121
+ }
122
+
123
+
113
124
/** @return PhpNamespace[] */
114
125
public function getNamespaces (): array
115
126
{
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ $file->addComment('This file is auto-generated. DO NOT EDIT!');
18
18
$ file ->addComment ('Hey there, I \'m here to document things. ' );
19
19
20
20
21
+ $ namespace = $ file ->addNamespace ('Deleted ' );
22
+ $ namespace ->addClass ('Foo ' );
23
+ $ file ->removeNamespace ('Deleted ' );
24
+
21
25
$ namespaceFoo = $ file ->addNamespace ('Foo ' );
22
26
23
27
$ classA = $ namespaceFoo ->addClass ('A ' );
You can’t perform that action at this time.
0 commit comments