1 | <?php |
||
18 | abstract class Controller extends \yii\console\Controller |
||
19 | { |
||
20 | use GettersTrait; |
||
21 | |||
22 | public $layout = false; |
||
23 | |||
24 | protected $_before = []; |
||
25 | protected $_after = []; |
||
26 | |||
27 | 1 | public function behaviors() |
|
33 | |||
34 | 1 | public function setBefore($requests) |
|
38 | |||
39 | 1 | public function getBefore() |
|
43 | |||
44 | public function setAfter($requests) |
||
48 | |||
49 | public function getAfter() |
||
53 | |||
54 | public function readline($prompt) |
||
55 | { |
||
56 | return readline($prompt); |
||
57 | } |
||
58 | |||
59 | public function readpassword($prompt) |
||
60 | { |
||
61 | echo $prompt; |
||
62 | system('stty -echo'); |
||
63 | $password = rtrim(fgets(STDIN), PHP_EOL); |
||
64 | system('stty echo'); |
||
65 | echo "\n"; |
||
66 | |||
67 | return $password; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Runs list of actions. |
||
72 | * @param null|string|array $actions |
||
73 | * @return int|Response exit code |
||
74 | */ |
||
75 | public function runActions($actions) |
||
88 | |||
89 | /** |
||
90 | * Is response Ok. |
||
91 | * @param Response|int $response |
||
92 | * @return bool |
||
93 | */ |
||
94 | public static function isResponseOk($response) |
||
98 | } |
||
99 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: