Skip to content

Commit

Permalink
Set typed = true as default for properties - Close #8
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrokeil committed Dec 11, 2020
1 parent a532ff6 commit db2ec95
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Builder/ClassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class ClassBuilder implements File
private bool $strict = false;

/** @var bool */
private bool $typed = false;
private bool $typed = true;

/** @var bool */
private bool $final = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/ClassMethodBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class ClassMethodBuilder
private int $visibility;

/** @var bool */
private bool $typed = false;
private bool $typed = true;

/**
* @var string|null
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/ClassPropertyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class ClassPropertyBuilder
private int $visibility;

/** @var bool */
private bool $typed = false;
private bool $typed = true;

/**
* @var string|null
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/InterfaceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class InterfaceBuilder implements File
private bool $strict = false;

/** @var bool */
private bool $typed = false;
private bool $typed = true;

/** @var string[] */
private array $extends = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Code/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class MethodGenerator extends AbstractMemberGenerator
/**
* @var bool
*/
private bool $typed = false;
private bool $typed = true;

/**
* @var string|null
Expand Down
2 changes: 1 addition & 1 deletion src/Code/PropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
string $name = null,
string $type = null,
$defaultValue = null,
bool $typed = false,
bool $typed = true,
int $flags = self::FLAG_PRIVATE
) {
if (null !== $name) {
Expand Down
2 changes: 1 addition & 1 deletion src/NodeVisitor/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function forClassProperty(
string $name = null,
string $type = null,
$defaultValue = null,
bool $typed = false,
bool $typed = true,
int $flags = PropertyGenerator::FLAG_PRIVATE
): self {
return new self(
Expand Down
8 changes: 4 additions & 4 deletions tests/Code/PropertyGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setUp(): void
*/
public function it_generates_property_with_doc_block(): void
{
$property = new PropertyGenerator('sourceFolder', 'string');
$property = new PropertyGenerator('sourceFolder', 'string', null, false);
$property->setDocBlockComment('source folder');

$expectedOutput = <<<'EOF'
Expand All @@ -62,7 +62,7 @@ public function it_generates_property_with_doc_block(): void
*/
public function it_generates_property_with_overridden_doc_block(): void
{
$property = new PropertyGenerator('sourceFolder', 'string');
$property = new PropertyGenerator('sourceFolder', 'string', null, false);
$property->setDocBlockComment('source folder');
$property->overrideDocBlock(new DocBlock('Awesome'));

Expand Down Expand Up @@ -92,7 +92,7 @@ public function it_generates_property_with_array_type_doc_block(): void
/**
* @var array<string, \stdClass>
*/
private $items;
private array $items;
EOF;

$this->assertSame($expectedOutput, $this->printer->prettyPrintFile([$property->generate()]));
Expand Down Expand Up @@ -130,7 +130,7 @@ public function it_generates_property_with_long_doc_block(): void
*
* @var string
*/
private $sourceFolder;
private string $sourceFolder;
EOF;

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

0 comments on commit db2ec95

Please sign in to comment.