Skip to content

Commit ccb981e

Browse files
Fix Psalm nits
1 parent 0391fb2 commit ccb981e

File tree

3 files changed

+6
-39
lines changed

3 files changed

+6
-39
lines changed

src/Filter/AllowList.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use ParagonIE\Ionizer\InputFilter;
66
use ParagonIE\Ionizer\InvalidDataException;
7+
use TypeError;
78

89
/**
910
* Class AllowList
@@ -25,10 +26,6 @@ public function __construct(...$values)
2526
$this->addToWhiteList(...$values);
2627
}
2728

28-
/**
29-
* @param array<int, scalar> $values
30-
* @return self
31-
*/
3229
protected function addToWhiteList(mixed ...$values): static
3330
{
3431
switch ($this->type) {
@@ -83,9 +80,7 @@ protected function addToWhiteList(mixed ...$values): static
8380
/**
8481
* Process data using the filter rules.
8582
*
86-
* @param mixed $data
87-
* @return mixed
88-
* @throws \TypeError
83+
* @throws TypeError
8984
* @throws InvalidDataException
9085
*/
9186
public function process(mixed $data = null): mixed

src/Filter/FloatFilter.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@ class FloatFilter extends InputFilter
3434
*/
3535
public function setMaximumValue(?float $value = null): static
3636
{
37-
if (is_null($value)) {
38-
$this->max = $value;
39-
return $this;
40-
}
41-
if (!is_numeric($value)) {
42-
throw new TypeError('A number was expected. ' . gettype($value) . ' given.');
43-
}
44-
$this->max = (float) $value;
37+
$this->max = $value;
4538
return $this;
4639
}
4740

@@ -50,14 +43,7 @@ public function setMaximumValue(?float $value = null): static
5043
*/
5144
public function setMinimumValue(?float $value = null): static
5245
{
53-
if (is_null($value)) {
54-
$this->min = $value;
55-
return $this;
56-
}
57-
if (!is_numeric($value)) {
58-
throw new TypeError('A number was expected. ' . gettype($value) . ' given.');
59-
}
60-
$this->min = (float) $value;
46+
$this->min = $value;
6147
return $this;
6248
}
6349

src/Filter/IntFilter.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@ class IntFilter extends InputFilter
4444
*/
4545
public function setMaximumValue(?int $value = null): static
4646
{
47-
if (is_null($value)) {
48-
$this->max = $value;
49-
return $this;
50-
}
51-
if (!is_int($value)) {
52-
throw new TypeError('An integer was expected. ' . gettype($value) . ' given.');
53-
}
54-
$this->max = (int) $value;
47+
$this->max = $value;
5548
return $this;
5649
}
5750

@@ -60,14 +53,7 @@ public function setMaximumValue(?int $value = null): static
6053
*/
6154
public function setMinimumValue(?int $value = null): static
6255
{
63-
if (is_null($value)) {
64-
$this->min = $value;
65-
return $this;
66-
}
67-
if (!is_int($value)) {
68-
throw new TypeError('An integer was expected. ' . gettype($value) . ' given.');
69-
}
70-
$this->min = (int) $value;
56+
$this->min = $value;
7157
return $this;
7258
}
7359

0 commit comments

Comments
 (0)