Skip to content

Commit b0a0068

Browse files
authored
Merge pull request #26 from open-code-modeling/0.5.x-merge-up-into-0.6.x_5fac5543948a63.21640314
Merge release 0.5.1 into 0.6.x
2 parents 39c024a + 77b03a0 commit b0a0068

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/Builder/ClassBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function fromNodes(Node ...$nodes): self
7373
}
7474

7575
public static function fromScratch(
76-
string $className,
76+
?string $className,
7777
string $namespace = null,
7878
bool $typed = true,
7979
bool $strict = true
@@ -148,6 +148,11 @@ public function getNamespace(): ?string
148148
return $this->namespace;
149149
}
150150

151+
public function setName(?string $name): void
152+
{
153+
$this->name = $name;
154+
}
155+
151156
public function getName(): ?string
152157
{
153158
return $this->name;

src/Code/ClassGenerator.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
namespace OpenCodeModeling\CodeAst\Code;
1212

13-
use PhpParser\Builder;
1413
use 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

0 commit comments

Comments
 (0)