Skip to content

Commit 206edb7

Browse files
committed
phpstan fixes
1 parent 0f1f728 commit 206edb7

11 files changed

+20
-12
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"nette/utils": "^3.0"
2222
},
2323
"require-dev": {
24+
"nette/application": "^3.0",
2425
"nette/di": "^3.0",
2526
"nette/tester": "^2.0",
2627
"latte/latte": "^2.8",

src/Forms/Controls/BaseControl.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
5050
/** @var Html label element template */
5151
protected $label;
5252

53-
/** @var bool */
53+
/** @var bool|bool[] */
5454
protected $disabled = false;
5555

5656
/** @var callable[][] extension methods */
@@ -68,7 +68,7 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
6868
/** @var Rules */
6969
private $rules;
7070

71-
/** @var Nette\Localization\ITranslator */
71+
/** @var Nette\Localization\ITranslator|bool|null */
7272
private $translator = true; // means autodetect
7373

7474
/** @var array user options */
@@ -200,9 +200,10 @@ public function setDefaultValue($value)
200200

201201
/**
202202
* Disables or enables control.
203+
* @param bool $value
203204
* @return static
204205
*/
205-
public function setDisabled(/*bool*/ $value = true)
206+
public function setDisabled($value = true)
206207
{
207208
if ($this->disabled = (bool) $value) {
208209
$this->setValue(null);

src/Forms/Controls/Button.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function isFilled(): bool
4343
*/
4444
public function getLabel($caption = null)
4545
{
46+
return null;
4647
}
4748

4849

src/Forms/Controls/Checkbox.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function getControl(): Html
6666
*/
6767
public function getLabel($caption = null)
6868
{
69+
return null;
6970
}
7071

7172

src/Forms/Controls/ChoiceControl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function loadHttpData(): void
5151

5252
/**
5353
* Sets selected item (by key).
54-
* @param string|int $value
54+
* @param string|int|null $value
5555
* @return static
5656
* @internal
5757
*/
@@ -68,7 +68,7 @@ public function setValue($value)
6868

6969
/**
7070
* Returns selected key.
71-
* @return string|int
71+
* @return string|int|null
7272
*/
7373
public function getValue()
7474
{

src/Forms/Controls/HiddenField.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function getControl(): Nette\Utils\Html
101101
*/
102102
public function getLabel($caption = null)
103103
{
104+
return null;
104105
}
105106

106107

src/Forms/Controls/MultiChoiceControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function getSelectedItems(): array
133133

134134
/**
135135
* Disables or enables control or items.
136-
* @param bool|bool[] $value
136+
* @param bool|array $value
137137
* @return static
138138
*/
139139
public function setDisabled($value = true)

src/Forms/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Form extends Container implements Nette\Utils\IHtmlString
102102
/** @var array */
103103
private $httpData;
104104

105-
/** @var Html <form> element */
105+
/** @var Html element <form> */
106106
private $element;
107107

108108
/** @var IFormRenderer */

src/Forms/Rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class Rule
3131
/** @var bool */
3232
public $isNegative = false;
3333

34-
/** @var string */
34+
/** @var string|null */
3535
public $message;
3636

37-
/** @var Rules for conditions */
37+
/** @var Rules|null for conditions */
3838
public $branch;
3939
}

src/Forms/Rules.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(IControl $control)
5454
public function setRequired($value = true)
5555
{
5656
if ($value) {
57-
$this->addRule(Form::REQUIRED, $value === true ? null : $value);
57+
$this->addRule(Form::FILLED, $value === true ? null : $value);
5858
} else {
5959
$this->required = null;
6060
}
@@ -88,7 +88,7 @@ public function addRule($validator, $errorMessage = null, $arg = null)
8888
$this->adjustOperation($rule);
8989
$rule->arg = $arg;
9090
$rule->message = $errorMessage;
91-
if ($rule->validator === Form::REQUIRED) {
91+
if ($rule->validator === Form::FILLED) {
9292
$this->required = $rule;
9393
} else {
9494
$this->rules[] = $rule;
@@ -104,7 +104,7 @@ public function addRule($validator, $errorMessage = null, $arg = null)
104104
*/
105105
public function removeRule($validator)
106106
{
107-
if ($validator === Form::REQUIRED) {
107+
if ($validator === Form::FILLED) {
108108
$this->required = null;
109109
} else {
110110
foreach ($this->rules as $i => $rule) {

tests/phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
includes:
22
- ../vendor/phpstan/phpstan-nette/extension.neon
3+
4+
parameters:
5+
treatPhpDocTypesAsCertain: false

0 commit comments

Comments
 (0)