1 | <?php |
||
23 | class SwitchAction extends Action implements \ArrayAccess, \IteratorAggregate, \yii\base\Arrayable |
||
24 | { |
||
25 | use \hiqdev\yii2\collection\ManagerTrait; |
||
26 | |||
27 | /** |
||
28 | * @var string|callable the success message or a callback, that returns string. |
||
29 | * Gets arguments |
||
30 | */ |
||
31 | public $success; |
||
32 | |||
33 | /** |
||
34 | * @var string the error message |
||
35 | */ |
||
36 | public $error; |
||
37 | |||
38 | /** |
||
39 | * @var SwitchRule instance of the current running rule |
||
40 | */ |
||
41 | public $rule; |
||
42 | |||
43 | /** {@inheritdoc} */ |
||
44 | public function init() |
||
45 | { |
||
46 | parent::init(); |
||
47 | |||
48 | $this->addItems($this->getDefaultRules()); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return array the default rules for the action. |
||
53 | * You can override this method in child classes to set own default rules. |
||
54 | */ |
||
55 | protected function getDefaultRules() |
||
56 | { |
||
57 | return []; |
||
58 | } |
||
59 | |||
60 | public function getItemConfig($name = null, array $config = []) |
||
72 | |||
73 | public function run() |
||
94 | |||
95 | /** |
||
96 | * Does perform only if rule has 'save' enabled. |
||
97 | */ |
||
98 | public function perform() |
||
106 | } |
||
107 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.