Skip to content

Commit c181ffc

Browse files
committed
added property typehints
1 parent 49268f6 commit c181ffc

24 files changed

+79
-162
lines changed

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ Need to customize printer behavior? Create your own by inheriting the `Printer`
772772
```php
773773
class MyPrinter extends Nette\PhpGenerator\Printer
774774
{
775-
protected $indentation = "\t";
776-
protected $linesBetweenProperties = 0;
777-
protected $linesBetweenMethods = 1;
778-
protected $returnTypeColon = ': ';
775+
protected string $indentation = "\t";
776+
protected int $linesBetweenProperties = 0;
777+
protected int $linesBetweenMethods = 1;
778+
protected string $returnTypeColon = ': ';
779779
}
780780
```

src/PhpGenerator/Attribute.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ final class Attribute
1919
{
2020
use Nette\SmartObject;
2121

22-
/** @var string */
23-
private $name;
24-
25-
/** @var array */
26-
private $args;
22+
private string $name;
23+
private array $args;
2724

2825

2926
public function __construct(string $name, array $args)

src/PhpGenerator/ClassType.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,37 @@ final class ClassType
3535
VISIBILITY_PROTECTED = 'protected',
3636
VISIBILITY_PRIVATE = 'private';
3737

38-
/** @var PhpNamespace|null */
39-
private $namespace;
38+
private ?PhpNamespace $namespace;
4039

41-
/** @var string|null */
42-
private $name;
40+
private ?string $name;
4341

44-
/** @var string class|interface|trait */
45-
private $type = self::TYPE_CLASS;
42+
/** class|interface|trait */
43+
private string $type = self::TYPE_CLASS;
4644

47-
/** @var bool */
48-
private $final = false;
45+
private bool $final = false;
4946

50-
/** @var bool */
51-
private $abstract = false;
47+
private bool $abstract = false;
5248

5349
/** @var string|string[] */
54-
private $extends = [];
50+
private string|array $extends = [];
5551

5652
/** @var string[] */
57-
private $implements = [];
53+
private array $implements = [];
5854

5955
/** @var TraitUse[] */
60-
private $traits = [];
56+
private array $traits = [];
6157

6258
/** @var Constant[] name => Constant */
63-
private $consts = [];
59+
private array $consts = [];
6460

6561
/** @var Property[] name => Property */
66-
private $properties = [];
62+
private array $properties = [];
6763

6864
/** @var Method[] name => Method */
69-
private $methods = [];
65+
private array $methods = [];
7066

7167
/** @var EnumCase[] name => EnumCase */
72-
private $cases = [];
68+
private array $cases = [];
7369

7470

7571
public static function class(?string $name): self

src/PhpGenerator/Closure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class Closure
2424
use Traits\AttributeAware;
2525

2626
/** @var Parameter[] */
27-
private $uses = [];
27+
private array $uses = [];
2828

2929

3030
public static function from(\Closure $closure): self

src/PhpGenerator/Constant.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ final class Constant
2323
use Traits\CommentAware;
2424
use Traits\AttributeAware;
2525

26-
/** @var mixed */
27-
private $value;
28-
29-
/** @var bool */
30-
private $final = false;
26+
private mixed $value;
27+
private bool $final = false;
3128

3229

3330
/** @return static */

src/PhpGenerator/Dumper.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ final class Dumper
1919
{
2020
private const INDENT_LENGTH = 4;
2121

22-
/** @var int */
23-
public $maxDepth = 50;
24-
25-
/** @var int */
26-
public $wrapLength = 120;
27-
28-
/** @var string */
29-
public $indentation = "\t";
22+
public int $maxDepth = 50;
23+
public int $wrapLength = 120;
24+
public string $indentation = "\t";
3025

3126

3227
/**

src/PhpGenerator/EnumCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ final class EnumCase
2222
use Traits\CommentAware;
2323
use Traits\AttributeAware;
2424

25-
/** @var string|int|null */
26-
private $value;
25+
private string|int|null $value = null;
2726

2827

2928
/** @return static */

src/PhpGenerator/Extractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ final class Extractor
2424
{
2525
use Nette\SmartObject;
2626

27-
private $code;
28-
private $statements;
29-
private $printer;
27+
private string $code;
28+
private array $statements;
29+
private PhpParser\PrettyPrinterAbstract $printer;
3030

3131

3232
public function __construct(string $code)

src/PhpGenerator/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ final class Factory
2020
{
2121
use Nette\SmartObject;
2222

23-
private $bodyCache = [];
24-
private $extractorCache = [];
23+
private array $bodyCache = [];
24+
private array $extractorCache = [];
2525

2626

2727
public function fromClassReflection(

src/PhpGenerator/Literal.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@
1515
*/
1616
class Literal
1717
{
18-
/** @var string */
19-
private $value;
20-
21-
/** @var ?array */
22-
private $args;
23-
24-
25-
public function __construct(string $value, ?array $args = null)
26-
{
27-
$this->value = $value;
28-
$this->args = $args;
18+
public function __construct(
19+
private string $value,
20+
private ?array $args = null,
21+
) {
2922
}
3023

3124

0 commit comments

Comments
 (0)