Skip to content

Commit 77d4c49

Browse files
committed
added property typehints
1 parent 686374f commit 77d4c49

25 files changed

Lines changed: 100 additions & 149 deletions

examples/custom-control.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818

1919
class DateInput extends Nette\Forms\Controls\BaseControl
2020
{
21-
/** @var string */
22-
private $day = '';
21+
private string $day = '';
2322

24-
private $month = '';
23+
private string $month = '';
2524

26-
private $year = '';
25+
private string $year = '';
2726

2827

2928
public function __construct($label = null)

src/Bridges/FormsDI/FormsExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct()
2121
{
2222
$this->config = new class {
2323
/** @var string[] */
24-
public $messages = [];
24+
public array $messages = [];
2525
};
2626
}
2727

src/Forms/Container.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess
3232
*/
3333
public $onValidate = [];
3434

35-
/** @var ControlGroup|null */
36-
protected $currentGroup;
35+
protected ?ControlGroup $currentGroup = null;
3736

3837
/** @var callable[] extension methods */
39-
private static $extMethods = [];
38+
private static array $extMethods = [];
4039

41-
/** @var bool */
42-
private $validated;
40+
private bool $validated = false;
4341

44-
/** @var ?string */
45-
private $mappedType;
42+
private ?string $mappedType = null;
4643

4744

4845
/********************* data exchange ****************d*g**/

src/Forms/ControlGroup.php

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

22-
/** @var \SplObjectStorage */
23-
protected $controls;
22+
protected \SplObjectStorage $controls;
2423

25-
/** @var array user options */
26-
private $options = [];
24+
private array $options = [];
2725

2826

2927
public function __construct()

src/Forms/Controls/BaseControl.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,34 @@
3838
*/
3939
abstract class BaseControl extends Nette\ComponentModel\Component implements Control
4040
{
41-
/** @var string */
42-
public static $idMask = 'frm-%s';
41+
public static string $idMask = 'frm-%s';
4342

44-
/** @var mixed current control value */
45-
protected $value;
43+
/** current control value */
44+
protected mixed $value;
4645

47-
/** @var Html control element template */
48-
protected $control;
46+
/** control element template */
47+
protected Html $control;
4948

50-
/** @var Html label element template */
51-
protected $label;
49+
/** label element template */
50+
protected Html $label;
5251

5352
/** @var bool|bool[] */
5453
protected $disabled = false;
5554

5655
/** @var callable[][] extension methods */
5756
private static $extMethods = [];
5857

59-
/** @var string|object textual caption or label */
60-
private $caption;
58+
private string|object|null $caption;
6159

62-
/** @var array */
63-
private $errors = [];
60+
private array $errors = [];
6461

65-
/** @var bool|null */
66-
private $omitted;
62+
private ?bool $omitted = null;
6763

68-
/** @var Rules */
69-
private $rules;
64+
private Rules $rules;
7065

71-
/** @var Nette\Localization\Translator|bool|null */
72-
private $translator = true; // means autodetect
66+
private Nette\Localization\Translator|bool|null $translator = true; // means autodetect
7367

74-
/** @var array user options */
75-
private $options = [];
68+
private array $options = [];
7669

7770

7871
/**

src/Forms/Controls/Checkbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class Checkbox extends BaseControl
2020
{
21-
/** @var Html wrapper element template */
22-
private $container;
21+
/** wrapper element template */
22+
private Html $container;
2323

2424

2525
/**

src/Forms/Controls/CheckboxList.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
*/
2323
class CheckboxList extends MultiChoiceControl
2424
{
25-
/** @var Html separator element template */
26-
protected $separator;
25+
/** separator element template */
26+
protected Html $separator;
2727

28-
/** @var Html container element template */
29-
protected $container;
28+
/** container element template */
29+
protected Html $container;
3030

31-
/** @var Html item label template */
32-
protected $itemLabel;
31+
/** item label template */
32+
protected Html $itemLabel;
3333

3434

3535
/**

src/Forms/Controls/ChoiceControl.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
*/
2121
abstract class ChoiceControl extends BaseControl
2222
{
23-
/** @var bool */
24-
private $checkDefaultValue = true;
23+
private bool $checkDefaultValue = true;
2524

26-
/** @var array */
27-
private $items = [];
25+
private array $items = [];
2826

2927

3028
public function __construct($label = null, array $items = null)

src/Forms/Controls/CsrfProtection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class CsrfProtection extends HiddenField
2020
{
2121
public const PROTECTION = 'Nette\Forms\Controls\CsrfProtection::validateCsrf';
2222

23-
/** @var Nette\Http\Session|null */
24-
public $session;
23+
public ?Nette\Http\Session $session = null;
2524

2625

2726
/**

src/Forms/Controls/HiddenField.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717
*/
1818
class HiddenField extends BaseControl
1919
{
20-
/** @var bool */
21-
private $persistValue;
20+
private bool $persistValue = false;
2221

23-
/** @var bool */
24-
private $nullable = false;
22+
private bool $nullable = false;
2523

2624

2725
public function __construct($persistentValue = null)
2826
{
2927
parent::__construct();
3028
$this->control->type = 'hidden';
3129
$this->setOption('type', 'hidden');
30+
$this->value = '';
3231
if ($persistentValue !== null) {
3332
$this->unmonitor(Nette\Forms\Form::class);
3433
$this->persistValue = true;

0 commit comments

Comments
 (0)