1 | <?php |
||
26 | class ModelFilter extends ActionFilter |
||
27 | { |
||
28 | /** |
||
29 | * The success handler key |
||
30 | */ |
||
31 | const SUCCESS_KEY = 'success'; |
||
32 | |||
33 | /** |
||
34 | * The fail handler key |
||
35 | */ |
||
36 | const FAIL_KEY = 'fail'; |
||
37 | |||
38 | /** |
||
39 | * @var array this property defines the transformers for each action. |
||
40 | * Each action that should only support one transformer. |
||
41 | * |
||
42 | * You can use `'*'` to stand for all actions. When an action is explicitly |
||
43 | * specified, it takes precedence over the specification given by `'*'`. |
||
44 | * |
||
45 | * For example, |
||
46 | * |
||
47 | * ```php |
||
48 | * [ |
||
49 | * 'create' => $handler, |
||
50 | * 'update' => $handler, |
||
51 | * 'delete' => $handler, |
||
52 | * '*' => $handler |
||
53 | * ] |
||
54 | * ``` |
||
55 | */ |
||
56 | public $actions = []; |
||
57 | |||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | public $handler = [ |
||
62 | self::SUCCESS_KEY => 'Successfully performed action', |
||
63 | self::FAIL_KEY => 'Unable to perform action' |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * @param \yii\base\Action $action |
||
68 | * @param mixed $result |
||
69 | * @return null|Model|Response |
||
70 | */ |
||
71 | public function afterAction($action, $result) |
||
78 | |||
79 | /** |
||
80 | * @param Model $model |
||
81 | * @return Model|null|Response |
||
82 | */ |
||
83 | protected function handleModel(Model $model) |
||
103 | |||
104 | /** |
||
105 | * @param array $handler |
||
106 | * @return mixed |
||
107 | */ |
||
108 | private function resolveSuccessMessage(array $handler) |
||
115 | |||
116 | /** |
||
117 | * @param array $handler |
||
118 | * @return mixed |
||
119 | */ |
||
120 | private function resolveFailMessage(array $handler) |
||
127 | |||
128 | /** |
||
129 | * @return ViewInterface|array|null |
||
130 | * @throws Exception |
||
131 | */ |
||
132 | protected function findHandler() |
||
155 | } |
||
156 |
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.