Skip to content

Commit 7ed7fbc

Browse files
committed
WIP
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent 3beb34d commit 7ed7fbc

File tree

9 files changed

+24
-20
lines changed

9 files changed

+24
-20
lines changed

src/Component/Method.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __toString(): string
3737
return $this->render();
3838
}
3939

40-
public function appendBody(string $string, int $spaces = 8, bool $newLine = true): self
40+
public function appendBody(string $string, int $spaces = 8, bool $newLine = true): static
4141
{
4242
if ($newLine === true) {
4343
$this->body .= PHP_EOL . str_repeat(' ', $spaces) . $string;
@@ -48,21 +48,21 @@ public function appendBody(string $string, int $spaces = 8, bool $newLine = true
4848
return $this;
4949
}
5050

51-
public function addInject(Inject $inject): self
51+
public function addInject(Inject $inject): static
5252
{
5353
$this->injects[] = $inject;
5454

5555
return $this;
5656
}
5757

58-
public function addParameter(ParameterInterface $parameter): self
58+
public function addParameter(ParameterInterface $parameter): static
5959
{
6060
$this->parameters[] = $parameter;
6161

6262
return $this;
6363
}
6464

65-
public function commentBody(): self
65+
public function commentBody(): static
6666
{
6767
$this->body = str_replace("\n", "\n// ", $this->body);
6868

@@ -74,7 +74,7 @@ public function getName(): string
7474
return $this->name;
7575
}
7676

77-
public function prependBody(string $bodyLine, int $spaces = 8): self
77+
public function prependBody(string $bodyLine, int $spaces = 8): static
7878
{
7979
$this->body = PHP_EOL . str_repeat(' ', $spaces) . $bodyLine . $this->body;
8080

@@ -190,35 +190,35 @@ public function renderSignature(): string
190190
return sprintf(': %s', $this->returnType);
191191
}
192192

193-
public function setBody(string $body): self
193+
public function setBody(string $body): static
194194
{
195195
$this->body = PHP_EOL . $body;
196196

197197
return $this;
198198
}
199199

200-
public function setComment(string $comment): self
200+
public function setComment(string $comment): static
201201
{
202202
$this->comment = $comment;
203203

204204
return $this;
205205
}
206206

207-
public function setNullable(bool $nullable): self
207+
public function setNullable(bool $nullable): static
208208
{
209209
$this->nullable = $nullable;
210210

211211
return $this;
212212
}
213213

214-
public function setReturnType(string $returnType): self
214+
public function setReturnType(string $returnType): static
215215
{
216216
$this->returnType = $returnType;
217217

218218
return $this;
219219
}
220220

221-
public function setVisibility(VisibilityEnum $visibility): self
221+
public function setVisibility(VisibilityEnum $visibility): static
222222
{
223223
$this->visibility = $visibility;
224224

src/Component/Method/Getter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function render(): string
2323
return <<<GTR
2424
{$this->visibility->value} function $this->name(): $nullable{$this->returnType}
2525
{
26-
return \$this->{$this->target->name};
26+
return \$this->{$this->target->getName()};
2727
}
2828
GTR;
2929
}

src/Component/Method/Setter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public function render(): string
2323
$nullable = $this->nullable ? '?' : '';
2424

2525
return <<<STR
26-
{$this->visibility->value} function $this->name($nullable$this->target->type \$$this->target->name): {$this->returnType}
26+
{$this->visibility->value} function $this->name($nullable$this->target->getType() \$$this->target->getName()): {$this->returnType}
2727
{
28-
\$this->$this->target->name = \$$this->target->name;
28+
\$this->$this->target->getName() = \$$this->target->getName();
2929
3030
return \$this;
3131
}

src/Component/MethodInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
interface MethodInterface
1010
{
11+
public function __toString(): string;
12+
1113
public function addInject(Inject $inject): self;
1214

1315
public function addParameter(ParameterInterface $parameter): self;

src/Component/Parameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public function render(int $spaces = 0): string
6363
return $parameter;
6464
}
6565

66-
public function setDefault(string $default): self
66+
public function setDefault(string $default): static
6767
{
6868
$this->default = $default;
6969

7070
return $this;
7171
}
7272

73-
public function setNullable(bool $nullable): self
73+
public function setNullable(bool $nullable): static
7474
{
7575
$this->nullable = $nullable;
7676

src/Component/ParameterInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
interface ParameterInterface
1111
{
12+
public function __toString(): string;
13+
1214
public function getGetter(): Getter;
1315

1416
public function getName(): string;

src/Type/AbstractType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020
protected FileSystem $fileSystem,
2121
protected ContextInterface $context,
2222
protected Config $config,
23-
protected ?Module $module = null,
23+
protected ?ModuleInterface $module = null,
2424
) {
2525
$this->import = new Import($context);
2626
}
@@ -40,14 +40,14 @@ public function getFileSystem(): FileSystem
4040
return $this->fileSystem;
4141
}
4242

43-
public function getModule(): ?Module
43+
public function getModule(): ?ModuleInterface
4444
{
4545
return $this->module;
4646
}
4747

4848
public function hasModule(): bool
4949
{
50-
return $this->module instanceof Module;
50+
return $this->module instanceof ModuleInterface;
5151
}
5252

5353
public function component(TypeEnum $typeEnum): FileInterface

src/Type/TypeInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function getContext(): ContextInterface;
1616

1717
public function getFileSystem(): FileSystem;
1818

19-
public function getModule(): ?Module;
19+
public function getModule(): ?ModuleInterface;
2020

2121
public function hasModule(): bool;
2222

test/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ protected function setup(): void
3838
public function testWillInstantiate(): void
3939
{
4040
$config = new Config($this->configPath);
41-
$this->assertInstanceOf(Config::class, $config);
41+
$this->assertContainsOnlyInstancesOf(Config::class, [$config]);
4242
}
4343
}

0 commit comments

Comments
 (0)