1 | <?php |
||
9 | class ArrayValidator extends AbstractValidator |
||
10 | { |
||
11 | /** |
||
12 | * ArrayValidator constructor. |
||
13 | * @param Comfort $comfort |
||
14 | */ |
||
15 | public function __construct(Comfort $comfort) |
||
48 | |||
49 | /** |
||
50 | * Given a set of keys apply the specified validation rules |
||
51 | * |
||
52 | * @param array $definition |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function keys(array $definition) |
||
78 | |||
79 | /** |
||
80 | * Validate array has more than $min elements |
||
81 | * |
||
82 | * @param $min |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function min($min) |
||
93 | |||
94 | /** |
||
95 | * Validate array has only up to $max characters |
||
96 | * |
||
97 | * @param $max |
||
98 | * @return $this |
||
99 | */ |
||
100 | public function max($max) |
||
108 | |||
109 | /** |
||
110 | * Validate array contains exactly $length elements |
||
111 | * |
||
112 | * @param $length |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function length($length) |
||
123 | |||
124 | /** |
||
125 | * Validate array is unique |
||
126 | * |
||
127 | * @return $this |
||
128 | */ |
||
129 | public function unique() |
||
137 | |||
138 | /** |
||
139 | * Apply $definition to individual items in the array, |
||
140 | * used in case of multi-dimensional array |
||
141 | * |
||
142 | * @param AbstractValidator $definition |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function items(AbstractValidator $definition) |
||
158 | } |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.