@@ -15,6 +15,6 @@ |
||
| 15 | 15 | { |
| 16 | 16 | public function modify($command) |
| 17 | 17 | { |
| 18 | - return 'sudo ' . $command; |
|
| 18 | + return 'sudo '.$command; |
|
| 19 | 19 | } |
| 20 | 20 | } |
@@ -19,11 +19,17 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class Helper |
| 21 | 21 | { |
| 22 | + /** |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 22 | 25 | public static function bad2sep($str, $separator = '-') |
| 23 | 26 | { |
| 24 | 27 | return preg_replace('/[^a-zA-Z0-9-]/', $separator, $str); |
| 25 | 28 | } |
| 26 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $id |
|
| 32 | + */ |
|
| 27 | 33 | public static function id2camel($id, $separator = '-') |
| 28 | 34 | { |
| 29 | 35 | return Inflector::id2camel(self::bad2sep($id, $separator), $separator); |
@@ -35,6 +41,9 @@ discard block |
||
| 35 | 41 | return str_replace('--', '-', Inflector::camel2id(str_replace(' ', '', ucwords($name)), $separator, $strict)); |
| 36 | 42 | } |
| 37 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string $file |
|
| 46 | + */ |
|
| 38 | 47 | public static function file2template($file, $separator = '-') |
| 39 | 48 | { |
| 40 | 49 | return trim($file, '.'); |
@@ -70,6 +79,9 @@ discard block |
||
| 70 | 79 | return array_combine($res, $res); |
| 71 | 80 | } |
| 72 | 81 | |
| 82 | + /** |
|
| 83 | + * @param string $subj |
|
| 84 | + */ |
|
| 73 | 85 | public static function getPublicVars($subj) |
| 74 | 86 | { |
| 75 | 87 | return is_object($subj) ? get_object_vars($subj) : get_class_vars($subj); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | 'name' => 'HiDev', |
| 15 | 15 | 'basePath' => dirname(__DIR__), |
| 16 | 16 | 'vendorPath' => HIDEV_VENDOR_DIR, |
| 17 | - 'runtimePath' => substr(__DIR__, 0, 7) === 'phar://' ? dirname($_SERVER['SCRIPT_NAME']) : dirname(HIDEV_VENDOR_DIR) . '/runtime', |
|
| 17 | + 'runtimePath' => substr(__DIR__, 0, 7) === 'phar://' ? dirname($_SERVER['SCRIPT_NAME']) : dirname(HIDEV_VENDOR_DIR).'/runtime', |
|
| 18 | 18 | 'enableCoreCommands' => false, |
| 19 | 19 | 'controllerNamespace' => 'hidev\\controllers', |
| 20 | 20 | 'defaultRoute' => 'default', |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | public function actionSave() |
| 53 | 53 | { |
| 54 | - $this->getFile()->write(implode(' ', [$this->version, $this->date, $this->time, $this->zone, $this->hash]) . "\n"); |
|
| 54 | + $this->getFile()->write(implode(' ', [$this->version, $this->date, $this->time, $this->zone, $this->hash])."\n"); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function setVersion($version = null) |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $this->package = $package; |
| 50 | 50 | } |
| 51 | 51 | if (!$this->package || !$this->vendor) { |
| 52 | - throw new InvalidParamException('Wrong vendor/package given: ' . $name); |
|
| 52 | + throw new InvalidParamException('Wrong vendor/package given: '.$name); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $path = parent::detectCommand($path); |
| 48 | 48 | |
| 49 | - return is_executable($path) ? $path : '/usr/bin/env php ' . $path; |
|
| 49 | + return is_executable($path) ? $path : '/usr/bin/env php '.$path; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function install() |
| 53 | 53 | { |
| 54 | 54 | if ($this->installer) { |
| 55 | - passthru('/usr/bin/env wget ' . escapeshellarg($this->installer) . ' -O- | /usr/bin/env php', $exitcode); |
|
| 55 | + passthru('/usr/bin/env wget '.escapeshellarg($this->installer).' -O- | /usr/bin/env php', $exitcode); |
|
| 56 | 56 | } elseif ($this->download) { |
| 57 | - $dest = Yii::getAlias('@root/' . $this->name . '.phar', false); |
|
| 58 | - passthru('/usr/bin/env wget ' . escapeshellarg($this->download) . ' -O ' . $dest, $exitcode); |
|
| 57 | + $dest = Yii::getAlias('@root/'.$this->name.'.phar', false); |
|
| 58 | + passthru('/usr/bin/env wget '.escapeshellarg($this->download).' -O '.$dest, $exitcode); |
|
| 59 | 59 | } else { |
| 60 | 60 | return parent::install(); |
| 61 | 61 | } |
@@ -65,6 +65,6 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function getVcsignore() |
| 67 | 67 | { |
| 68 | - return $this->name . '.phar'; |
|
| 68 | + return $this->name.'.phar'; |
|
| 69 | 69 | } |
| 70 | 70 | } |
@@ -143,6 +143,9 @@ discard block |
||
| 143 | 143 | return $type2extension[$type]; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | + /** |
|
| 147 | + * @param string $extension |
|
| 148 | + */ |
|
| 146 | 149 | public function getTypeByExtension($extension) |
| 147 | 150 | { |
| 148 | 151 | return isset(static::$_extension2type[$extension]) ? static::$_extension2type[$extension] : null; |
@@ -157,6 +160,9 @@ discard block |
||
| 157 | 160 | return ($this->goal ? $this->goal->fileType : null) ?: static::getTypeByExtension($this->_extension) ?: 'template'; |
| 158 | 161 | } |
| 159 | 162 | |
| 163 | + /** |
|
| 164 | + * @param string $path |
|
| 165 | + */ |
|
| 160 | 166 | public function setPath($path) |
| 161 | 167 | { |
| 162 | 168 | $path = Yii::getAlias($path); |
@@ -233,6 +239,9 @@ discard block |
||
| 233 | 239 | return $this->getHandler()->renderPath($this->getPath(), $this->data); |
| 234 | 240 | } |
| 235 | 241 | |
| 242 | + /** |
|
| 243 | + * @param string $content |
|
| 244 | + */ |
|
| 236 | 245 | public function write($content) |
| 237 | 246 | { |
| 238 | 247 | return $this->getHandler()->write($this->getPath(), $content); |
@@ -243,6 +252,9 @@ discard block |
||
| 243 | 252 | return $this->data = $this->getHandler()->parsePath($this->getPath(), $this->getMinimalPath()); |
| 244 | 253 | } |
| 245 | 254 | |
| 255 | + /** |
|
| 256 | + * @return string |
|
| 257 | + */ |
|
| 246 | 258 | public function read() |
| 247 | 259 | { |
| 248 | 260 | return $this->getHandler()->read($this->getPath()); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | protected static $_extension2type = [ |
| 125 | 125 | 'json' => 'json', |
| 126 | - 'yml' => 'yaml', /// first one is preferred |
|
| 126 | + 'yml' => 'yaml', /// first one is preferred |
|
| 127 | 127 | 'yaml' => 'yaml', |
| 128 | 128 | 'xml' => 'xml', |
| 129 | 129 | 'xml.dist' => 'xml', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | public function setBasename($basename) |
| 178 | 178 | { |
| 179 | - $this->setPath($this->_dirname . '/' . $basename); |
|
| 179 | + $this->setPath($this->_dirname.'/'.$basename); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function getBasename() |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | public function setDirname($dirname) |
| 188 | 188 | { |
| 189 | - $this->setPath($dirname . '/' . $this->_basename); |
|
| 189 | + $this->setPath($dirname.'/'.$this->_basename); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function getDirname() |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | public function setFilename($filename) |
| 198 | 198 | { |
| 199 | - $this->setPath($this->_dirname . '/' . $filename . '.' . $this->_extension); |
|
| 199 | + $this->setPath($this->_dirname.'/'.$filename.'.'.$this->_extension); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function getFilename() |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | public function setExtension($extension) |
| 208 | 208 | { |
| 209 | - $this->setPath($this->_dirname . '/' . $this->_filename . '.' . $extension); |
|
| 209 | + $this->setPath($this->_dirname.'/'.$this->_filename.'.'.$extension); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | public function getExtension() |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | { |
| 258 | 258 | if (!is_object($this->_handler)) { |
| 259 | 259 | $this->_handler = Yii::createObject([ |
| 260 | - 'class' => 'hidev\handlers\\' . $this->getCtype() . 'Handler', |
|
| 260 | + 'class' => 'hidev\handlers\\'.$this->getCtype().'Handler', |
|
| 261 | 261 | 'template' => $this->template, |
| 262 | 262 | 'goal' => $this->goal, |
| 263 | 263 | ]); |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | public function chown($value) |
| 362 | 362 | { |
| 363 | - $ownergroup = $this->getOwner() . ':' . $this->getGroup(); |
|
| 363 | + $ownergroup = $this->getOwner().':'.$this->getGroup(); |
|
| 364 | 364 | if (in_array((string) $value, [$ownergroup, $this->getOwner(), $this->getUid()], true)) { |
| 365 | 365 | return; |
| 366 | 366 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * @return int|Response exit code |
|
| 50 | + * @return null|integer exit code |
|
| 51 | 51 | */ |
| 52 | 52 | public function actionMake() |
| 53 | 53 | { |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * Is response NOT Ok. |
| 143 | 143 | * @param Response|int $res |
| 144 | - * @return bool |
|
| 144 | + * @return integer |
|
| 145 | 145 | */ |
| 146 | 146 | public static function isNotOk($res) |
| 147 | 147 | { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Is response Ok. |
| 153 | - * @param Response|int $res |
|
| 153 | + * @param integer $res |
|
| 154 | 154 | * @return bool |
| 155 | 155 | */ |
| 156 | 156 | public static function isOk($res) |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * Runs list of actions. |
| 163 | 163 | * TODO: think to redo with runRequests. |
| 164 | 164 | * @param null|string|array $actions |
| 165 | - * @return int|Response exit code |
|
| 165 | + * @return null|integer exit code |
|
| 166 | 166 | */ |
| 167 | 167 | public function runActions($actions) |
| 168 | 168 | { |
@@ -244,6 +244,9 @@ discard block |
||
| 244 | 244 | return readline($prompt); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | + /** |
|
| 248 | + * @param string $prompt |
|
| 249 | + */ |
|
| 247 | 250 | public function readpassword($prompt) |
| 248 | 251 | { |
| 249 | 252 | echo $prompt; |
@@ -255,6 +258,9 @@ discard block |
||
| 255 | 258 | return $password; |
| 256 | 259 | } |
| 257 | 260 | |
| 261 | + /** |
|
| 262 | + * @param string $id |
|
| 263 | + */ |
|
| 258 | 264 | public function takeGoal($id) |
| 259 | 265 | { |
| 260 | 266 | return $this->module->get('config')->getGoal($id); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | foreach ($this->getItems() as $id => $config) { |
| 41 | 41 | $defaults = [ |
| 42 | 42 | 'class' => isset($config['template']) || isset($config['copy']) ? 'template' : 'directory', |
| 43 | - 'file' => $this->path . '/' . $id, |
|
| 43 | + 'file' => $this->path.'/'.$id, |
|
| 44 | 44 | ]; |
| 45 | 45 | if ($this->recursive) { |
| 46 | 46 | $defaults['recursive'] = $this->recursive; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function mkdir($path) |
| 59 | 59 | { |
| 60 | - Yii::warning('mkdir ' . $path, 'dir'); |
|
| 60 | + Yii::warning('mkdir '.$path, 'dir'); |
|
| 61 | 61 | mkdir($path); |
| 62 | 62 | } |
| 63 | 63 | } |