1 | <?php |
||||
2 | |||||
3 | $input = ' hoge fuga '; |
||||
4 | $rule = ['trim', 'empty_to_null']; |
||||
5 | |||||
6 | $result = Normalizer::normalize($input, $rule); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
7 | |||||
8 | var_dump($result); |
||||
9 | // 'hoge fuga' |
||||
10 | |||||
11 | $n = new Normalizer([ |
||||
12 | 'name' => ['trim', 'empty_to_null'], |
||||
13 | 'age' => ['trim', 'empty_to_null', 'integer'], |
||||
14 | 'gender' => ['trim', 'empty_to_null', 'integer'], |
||||
15 | ]); |
||||
16 | |||||
17 | $normalized = $n->normalize([ |
||||
0 ignored issues
–
show
array('name' => ' hog...uga ', 'age' => ' 20 ') of type array<string,string> is incompatible with the type string expected by parameter $input of Normalizer::normalize() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
18 | 'name' => ' hoge fuga ', |
||||
19 | 'age' => ' 20 ', |
||||
20 | ]); |
||||
21 | |||||
22 | var_dump($result); |
||||
23 | // [ |
||||
24 | // 'name' => 'hoge fuga', |
||||
25 | // 'age' => 20, |
||||
26 | // 'gender' => null, |
||||
27 | // ] |
||||
28 | |||||
29 | // Advanced Filters |
||||
30 | |||||
31 | Filter::map([ |
||||
32 | '1' => 'male', |
||||
33 | '2' => 'female', |
||||
34 | ]); |
||||
35 | Filter::substitute('aaa', 'bbb'); |
||||
36 | |||||
37 | // Add Filter |
||||
38 | |||||
39 | // Filter Set |
||||
40 | Normalizer::STRING; |
||||
0 ignored issues
–
show
|
|||||
41 | Normalizer::INTEGER; |
||||
0 ignored issues
–
show
|
|||||
42 | |||||
43 | |||||
44 | var_dump($normalized); |