File tree 2 files changed +15
-15
lines changed
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public static function fromNodes(Node ...$nodes): self
80
80
}
81
81
82
82
public static function fromScratch (
83
- string $ className ,
83
+ ? string $ className ,
84
84
string $ namespace = null ,
85
85
bool $ typed = true ,
86
86
bool $ strict = true
@@ -196,6 +196,11 @@ public function getNamespace(): ?string
196
196
return $ this ->namespace ;
197
197
}
198
198
199
+ public function setName (?string $ name ): void
200
+ {
201
+ $ this ->name = $ name ;
202
+ }
203
+
199
204
public function getName (): ?string
200
205
{
201
206
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