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 @@ -69,7 +69,7 @@ public static function fromNodes(Node ...$nodes): self
69
69
}
70
70
71
71
public static function fromScratch (
72
- string $ className ,
72
+ ? string $ className ,
73
73
string $ namespace = null ,
74
74
bool $ typed = true ,
75
75
bool $ strict = true
@@ -137,6 +137,11 @@ public function getNamespace(): ?string
137
137
return $ this ->namespace ;
138
138
}
139
139
140
+ public function setName (?string $ name ): void
141
+ {
142
+ $ this ->name = $ name ;
143
+ }
144
+
140
145
public function getName (): ?string
141
146
{
142
147
return $ this ->name ;
Original file line number Diff line number Diff line change 10
10
11
11
namespace OpenCodeModeling \CodeAst \Code ;
12
12
13
- use PhpParser \Builder ;
14
13
use PhpParser \Node \Stmt \Class_ ;
15
14
16
15
/**
@@ -37,11 +36,11 @@ final class ClassGenerator implements StatementGenerator
37
36
private $ flags = 0 ;
38
37
39
38
/**
40
- * @param string $name
39
+ * @param string|null $name
41
40
* @param array|string $flags
42
41
*/
43
42
public function __construct (
44
- $ name ,
43
+ ? string $ name ,
45
44
$ flags = null
46
45
) {
47
46
$ this ->setName ($ name );
@@ -53,19 +52,15 @@ public function __construct(
53
52
54
53
public function generate (): Class_
55
54
{
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
+ ) ;
62
61
}
63
62
64
- /**
65
- * @param string $name
66
- * @return self
67
- */
68
- public function setName (string $ name ): self
63
+ public function setName (?string $ name ): self
69
64
{
70
65
$ this ->name = $ name ;
71
66
You can’t perform that action at this time.
0 commit comments