Skip to content

Commit 227c2fb

Browse files
committed
fix phpstan & add missing types
1 parent bba734d commit 227c2fb

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

.phpstan.neon

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ includes:
33
- vendor/phpstan/phpstan-nette/rules.neon
44

55
parameters:
6-
ignoreErrors:
7-
excludes_analyse:
8-
- %currentWorkingDirectory%/src/Fragments/Traits/*
6+
level: 8
7+
paths:
8+
- src
9+
excludePaths:
10+
- %currentWorkingDirectory%/src/Fragments/Traits/*

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@
2323
"nette/di": "~3.0",
2424
"nette/robot-loader": "~3.0",
2525
"nette/tester": "~2.1",
26-
"phpstan/phpstan-nette": "0.11",
27-
"phpstan/phpstan-shim": "0.11.1",
26+
"phpstan/phpstan-nette": "^1.3",
27+
"phpstan/phpstan": "^1.12",
2828
"tracy/tracy": "~2.5"
2929
},
3030
"extra": {
3131
"branch-alias": {
3232
"dev-master": "1.0-dev"
3333
}
3434
},
35+
"scripts": {
36+
"phpstan": "phpstan analyse -c .phpstan.neon --memory-limit 1G",
37+
"tests": "tester -C --colors 1 ./tests/cases"
38+
},
3539
"minimum-stability": "beta",
3640
"prefer-stable": true,
3741
"config": {

src/Controls/AutocompleteControl.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ public function getControl(): Html
4747
}
4848

4949

50-
public function setCallback(callable $callback)
50+
/**
51+
* @param callable(string $input):mixed $callback
52+
*/
53+
public function setCallback(callable $callback): void
5154
{
5255
$this->callback = $callback;
5356
}
5457

5558

56-
public function handleAutocomplete(string $q)
59+
public function handleAutocomplete(string $q): void
5760
{
5861
if (!$this->callback) {
5962
throw new InvalidStateException('Undefined autocomplete callback.');

src/Controls/DateTimeControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DateTimeControl extends DateTimeControlPrototype
2424
protected $htmlType = 'datetime-local';
2525

2626

27-
protected function getDefaultParser()
27+
protected function getDefaultParser(): callable
2828
{
2929
return function($value) {
3030
try {

src/Controls/DateTimeControlPrototype.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,25 @@ public function getValue(): ?DateTimeImmutable
9595
}
9696

9797

98-
public function addParser(callable $parser)
98+
public function addParser(callable $parser): self
9999
{
100100
$this->parsers[] = $parser;
101101
return $this;
102102
}
103103

104104

105+
/**
106+
* @return callable(string $input):(DateTimeImmutable|null)
107+
*/
105108
abstract protected function getDefaultParser();
106109

107110

108111
/**
109112
* Finds minimum and maximum allowed dates.
110113
*
111-
* @return array 0 => DateTime|null $minDate, 1 => DateTime|null $maxDate
114+
* @return array{DateTime|null,DateTime|null} 0 => DateTime|null $minDate, 1 => DateTime|null $maxDate
112115
*/
113-
protected function extractRangeRule(Rules $rules)
116+
protected function extractRangeRule(Rules $rules): array
114117
{
115118
$controlMin = $controlMax = null;
116119
/** @var Nette\Forms\Rule $rule */

0 commit comments

Comments
 (0)