Skip to content

Commit db2ec95

Browse files
committed
Set typed = true as default for properties - Close #8
1 parent a532ff6 commit db2ec95

8 files changed

+11
-11
lines changed

src/Builder/ClassBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class ClassBuilder implements File
3535
private bool $strict = false;
3636

3737
/** @var bool */
38-
private bool $typed = false;
38+
private bool $typed = true;
3939

4040
/** @var bool */
4141
private bool $final = false;

src/Builder/ClassMethodBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class ClassMethodBuilder
4444
private int $visibility;
4545

4646
/** @var bool */
47-
private bool $typed = false;
47+
private bool $typed = true;
4848

4949
/**
5050
* @var string|null

src/Builder/ClassPropertyBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class ClassPropertyBuilder
3636
private int $visibility;
3737

3838
/** @var bool */
39-
private bool $typed = false;
39+
private bool $typed = true;
4040

4141
/**
4242
* @var string|null

src/Builder/InterfaceBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class InterfaceBuilder implements File
3333
private bool $strict = false;
3434

3535
/** @var bool */
36-
private bool $typed = false;
36+
private bool $typed = true;
3737

3838
/** @var string[] */
3939
private array $extends = [];

src/Code/MethodGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class MethodGenerator extends AbstractMemberGenerator
4545
/**
4646
* @var bool
4747
*/
48-
private bool $typed = false;
48+
private bool $typed = true;
4949

5050
/**
5151
* @var string|null

src/Code/PropertyGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
string $name = null,
6161
string $type = null,
6262
$defaultValue = null,
63-
bool $typed = false,
63+
bool $typed = true,
6464
int $flags = self::FLAG_PRIVATE
6565
) {
6666
if (null !== $name) {

src/NodeVisitor/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function forClassProperty(
3333
string $name = null,
3434
string $type = null,
3535
$defaultValue = null,
36-
bool $typed = false,
36+
bool $typed = true,
3737
int $flags = PropertyGenerator::FLAG_PRIVATE
3838
): self {
3939
return new self(

tests/Code/PropertyGeneratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function setUp(): void
4040
*/
4141
public function it_generates_property_with_doc_block(): void
4242
{
43-
$property = new PropertyGenerator('sourceFolder', 'string');
43+
$property = new PropertyGenerator('sourceFolder', 'string', null, false);
4444
$property->setDocBlockComment('source folder');
4545

4646
$expectedOutput = <<<'EOF'
@@ -62,7 +62,7 @@ public function it_generates_property_with_doc_block(): void
6262
*/
6363
public function it_generates_property_with_overridden_doc_block(): void
6464
{
65-
$property = new PropertyGenerator('sourceFolder', 'string');
65+
$property = new PropertyGenerator('sourceFolder', 'string', null, false);
6666
$property->setDocBlockComment('source folder');
6767
$property->overrideDocBlock(new DocBlock('Awesome'));
6868

@@ -92,7 +92,7 @@ public function it_generates_property_with_array_type_doc_block(): void
9292
/**
9393
* @var array<string, \stdClass>
9494
*/
95-
private $items;
95+
private array $items;
9696
EOF;
9797

9898
$this->assertSame($expectedOutput, $this->printer->prettyPrintFile([$property->generate()]));
@@ -130,7 +130,7 @@ public function it_generates_property_with_long_doc_block(): void
130130
*
131131
* @var string
132132
*/
133-
private $sourceFolder;
133+
private string $sourceFolder;
134134
EOF;
135135

136136
$this->assertSame($expectedOutput, $this->printer->prettyPrintFile([$property->generate()]));

0 commit comments

Comments
 (0)