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 @@ -76,7 +76,7 @@ public static function fromNodes(Node ...$nodes): self
76
76
}
77
77
78
78
public static function fromScratch (
79
- string $ className ,
79
+ ? string $ className ,
80
80
string $ namespace = null ,
81
81
bool $ typed = true ,
82
82
bool $ strict = true
@@ -158,6 +158,11 @@ public function getNamespace(): ?string
158
158
return $ this ->namespace ;
159
159
}
160
160
161
+ public function setName (?string $ name ): void
162
+ {
163
+ $ this ->name = $ name ;
164
+ }
165
+
161
166
public function getName (): ?string
162
167
{
163
168
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