1 | <?php |
||
10 | class MultipleValidationWithAnd implements EmailValidation |
||
11 | { |
||
12 | /** |
||
13 | * If one of validations fails, the remaining validations will be skept. |
||
14 | * This means MultipleErrors will only contain a single error, the first found. |
||
15 | */ |
||
16 | const STOP_ON_ERROR = 0; |
||
17 | |||
18 | /** |
||
19 | * All of validations will be invoked even if one of them got failure. |
||
20 | * So MultipleErrors will contain all causes. |
||
21 | */ |
||
22 | const ALLOW_ALL_ERRORS = 1; |
||
23 | |||
24 | /** |
||
25 | * @var EmailValidation[] |
||
26 | */ |
||
27 | private $validations = []; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $warnings = []; |
||
33 | |||
34 | /** |
||
35 | * @var MultipleErrors|null |
||
36 | */ |
||
37 | private $error; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | private $mode; |
||
43 | |||
44 | /** |
||
45 | * @param EmailValidation[] $validations The validations. |
||
46 | * @param int $mode The validation mode (one of the constants). |
||
47 | */ |
||
48 | public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function isValid($email, EmailLexer $emailLexer) |
||
79 | |||
80 | private function processValidation(EmailValidation $validation) |
||
87 | |||
88 | /** |
||
89 | * @param bool $result |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | private function shouldStop($result) |
||
97 | |||
98 | /** |
||
99 | * Returns the validation errors. |
||
100 | * |
||
101 | */ |
||
102 | public function getError() : InvalidEmail |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | public function getWarnings() |
||
114 | } |
||
115 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.