Issues (6)

memo.php (3 issues)

1
<?php
2
3
$input = '   hoge  fuga ';
4
$rule  = ['trim', 'empty_to_null'];
5
6
$result = Normalizer::normalize($input, $rule);
0 ignored issues
show
$rule of type array<integer,string> is incompatible with the type string expected by parameter $form of Normalizer::normalize(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

6
$result = Normalizer::normalize($input, /** @scrutinizer ignore-type */ $rule);
Loading history...
7
8
var_dump($result);
9
// 'hoge  fuga'
10
11
$n = new Normalizer([
0 ignored issues
show
The call to Normalizer::__construct() has too many arguments starting with array('name' => array('t...y_to_null', 'integer')). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
$n = /** @scrutinizer ignore-call */ new Normalizer([

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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 ignore-type  annotation

17
$normalized = $n->normalize(/** @scrutinizer ignore-type */ [
Loading history...
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;
41
Normalizer::INTEGER;
42
43
44
var_dump($normalized);