1 | <?php |
||
22 | class StartController extends CommonController |
||
23 | { |
||
24 | const MAIN_CONFIG = '.hidev/config.yml'; |
||
25 | |||
26 | /** |
||
27 | * @var string absolute path to the project root directory |
||
28 | */ |
||
29 | protected $_rootDir; |
||
30 | |||
31 | /** |
||
32 | * @var bool hidev already started flag |
||
33 | */ |
||
34 | public static $started = false; |
||
35 | |||
36 | /** |
||
37 | * Make action. |
||
38 | */ |
||
39 | public function actionMake() |
||
50 | |||
51 | public function addAutoloader() |
||
60 | |||
61 | /** |
||
62 | * Update action. |
||
63 | * @return int exit code |
||
64 | */ |
||
65 | public function actionUpdate() |
||
66 | { |
||
67 | return $this->passthru('composer', ['update', '-d', '.hidev', '--prefer-source', '--ansi']); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Adds aliases: |
||
72 | * - @root alias to current project root dir |
||
73 | * - current package namespace for it could be used from hidev. |
||
74 | */ |
||
75 | public function addAliases() |
||
76 | { |
||
77 | Yii::setAlias('@root', $this->getRootDir()); |
||
78 | $config = $this->takeConfig()->rawItem('package'); |
||
79 | $alias = strtr($config['namespace'], '\\', '/'); |
||
80 | if ($alias && !Yii::getAlias('@' . $alias, false)) { |
||
81 | $srcdir = Yii::getAlias('@root/' . ($config['src'] ?: 'src')); |
||
82 | Yii::setAlias($alias, $srcdir); |
||
|
|||
83 | } |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Require all configured requires. |
||
88 | */ |
||
89 | protected function requireAll() |
||
117 | |||
118 | public function needsComposerInstall() |
||
140 | |||
141 | /** |
||
142 | * Include all configs. |
||
143 | */ |
||
144 | public function includeAll() |
||
157 | |||
158 | /** |
||
159 | * Load project's config if configured. |
||
160 | */ |
||
161 | public function loadConfig() |
||
168 | |||
169 | public function setRootDir($value) |
||
170 | { |
||
173 | |||
174 | public function getRootDir() |
||
182 | |||
183 | /** |
||
184 | * Chdirs to project's root by looking for config file in the current directory and up. |
||
185 | * @throws InvalidParamException when failed to find |
||
186 | * @return string path to the root directory of hidev project |
||
187 | */ |
||
188 | protected function findRootDir() |
||
199 | } |
||
200 |
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.