File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ public static function fromNodes(Node ...$nodes): self
7676 }
7777
7878 public static function fromScratch (
79- string $ className ,
79+ ? string $ className ,
8080 string $ namespace = null ,
8181 bool $ typed = true ,
8282 bool $ strict = true
@@ -158,6 +158,11 @@ public function getNamespace(): ?string
158158 return $ this ->namespace ;
159159 }
160160
161+ public function setName (?string $ name ): void
162+ {
163+ $ this ->name = $ name ;
164+ }
165+
161166 public function getName (): ?string
162167 {
163168 return $ this ->name ;
Original file line number Diff line number Diff line change 1010
1111namespace OpenCodeModeling \CodeAst \Code ;
1212
13- use PhpParser \Builder ;
1413use PhpParser \Node \Stmt \Class_ ;
1514
1615/**
@@ -37,11 +36,11 @@ final class ClassGenerator implements StatementGenerator
3736 private $ flags = 0 ;
3837
3938 /**
40- * @param string $name
39+ * @param string|null $name
4140 * @param array|string $flags
4241 */
4342 public function __construct (
44- $ name ,
43+ ? string $ name ,
4544 $ flags = null
4645 ) {
4746 $ this ->setName ($ name );
@@ -53,19 +52,15 @@ public function __construct(
5352
5453 public function generate (): Class_
5554 {
56- $ classBuilder = new Builder \ Class_ ($ this -> name );
57- $ node = $ classBuilder -> getNode ();
58-
59- $ node -> flags = $ this ->flags ;
60-
61- return $ node ;
55+ return new Class_ (
56+ $ this -> name ,
57+ [
58+ ' flags ' => $ this ->flags ,
59+ ]
60+ ) ;
6261 }
6362
64- /**
65- * @param string $name
66- * @return self
67- */
68- public function setName (string $ name ): self
63+ public function setName (?string $ name ): self
6964 {
7065 $ this ->name = $ name ;
7166
You can’t perform that action at this time.
0 commit comments