Skip to content

Commit 41e710b

Browse files
authored
Reactor: add methods to set and get constant type (#1220)
issue #1216
1 parent 0a51689 commit 41e710b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/Reactor/src/Partial/Constant.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ public function isFinal(): bool
6363
return $this->element->isFinal();
6464
}
6565

66+
public function setType(?string $type): self
67+
{
68+
$this->element->setType($type);
69+
70+
return $this;
71+
}
72+
73+
public function getType(): ?string
74+
{
75+
return $this->element->getType();
76+
}
77+
6678
/**
6779
* @internal
6880
*/

src/Reactor/tests/Partial/ConstantTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ public function testComment(): void
4747
self::assertNull($constant->getComment());
4848

4949
$constant->setComment(['/** Line one */', '/** Line two */']);
50-
self::assertSame(\preg_replace('/\s+/', '', '/** Line one *//** Line two */'), \preg_replace('/\s+/', '', $constant->getComment()));
50+
self::assertSame(
51+
\preg_replace('/\s+/', '', '/** Line one *//** Line two */'),
52+
\preg_replace('/\s+/', '', $constant->getComment()),
53+
);
5154

5255
$constant->setComment(null);
5356
$constant->addComment('/** Line one */');
5457
$constant->addComment('/** Line two */');
55-
self::assertSame(\preg_replace('/\s+/', '', '/** Line one *//** Line two */'), \preg_replace('/\s+/', '', $constant->getComment()));
58+
self::assertSame(
59+
\preg_replace('/\s+/', '', '/** Line one *//** Line two */'),
60+
\preg_replace('/\s+/', '', $constant->getComment()),
61+
);
5662
}
5763

5864
public function testValue(): void
@@ -81,6 +87,16 @@ public function testFinal(): void
8187
self::assertTrue($constant->isFinal());
8288
}
8389

90+
public function testType(): void
91+
{
92+
$constant = new Constant('TEST');
93+
94+
self::assertNull($constant->getType());
95+
96+
$constant->setType('null');
97+
self::assertSame('null', $constant->getType());
98+
}
99+
84100
public function testFromElement(): void
85101
{
86102
$constant = Constant::fromElement(new NetteConstant('TEST'));

0 commit comments

Comments
 (0)