| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | */ | 
| 24 | 24 | public function renderType($data) | 
| 25 | 25 |      { | 
| 26 | - return Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n"; | |
| 26 | + return Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)."\n"; | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 | /** | 
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | $res = ''; | 
| 49 | 49 |          foreach ($comments as $comment => $items) { | 
| 50 | 50 | ksort($items); | 
| 51 | -            $res .= static::renderComment($comment) . implode("\n", $items) . "\n"; | |
| 51 | +            $res .= static::renderComment($comment).implode("\n", $items)."\n"; | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 | return ltrim($res); | 
| @@ -56,6 +56,6 @@ discard block | ||
| 56 | 56 | |
| 57 | 57 | public static function renderComment($comment) | 
| 58 | 58 |      { | 
| 59 | - return "\n#" . ($comment[0] === '#' ? '' : ' ') . "$comment\n"; | |
| 59 | + return "\n#".($comment[0] === '#' ? '' : ' ')."$comment\n"; | |
| 60 | 60 | } | 
| 61 | 61 | } | 
| @@ -65,14 +65,14 @@ discard block | ||
| 65 | 65 |      { | 
| 66 | 66 | $command = $this->getCommand(); | 
| 67 | 67 |          if (is_string($args)) { | 
| 68 | - return $command . ' ' . trim($args); | |
| 68 | + return $command.' '.trim($args); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 |          foreach ($args as $arg) { | 
| 72 | 72 |              if ($arg instanceof ModifierInterface) { | 
| 73 | 73 | $command = $arg->modify($command); | 
| 74 | 74 |              } else { | 
| 75 | - $command .= ' ' . escapeshellarg($arg); | |
| 75 | + $command .= ' '.escapeshellarg($arg); | |
| 76 | 76 | } | 
| 77 | 77 | } | 
| 78 | 78 | |
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | |
| 82 | 82 | public function install() | 
| 83 | 83 |      { | 
| 84 | -        throw new InvalidConfigException('Don\'t know how to install ' . $this->name); | |
| 84 | +        throw new InvalidConfigException('Don\'t know how to install '.$this->name); | |
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | 87 | /** | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | */ | 
| 114 | 114 | public function detectPath($name) | 
| 115 | 115 |      { | 
| 116 | -        return exec('which ' . $name) ?: null; | |
| 116 | +        return exec('which '.$name) ?: null; | |
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | 119 | /** | 
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | $path = $this->getPath(); | 
| 149 | 149 | } | 
| 150 | 150 |          if (!$path || !file_exists($path)) { | 
| 151 | -            throw new InvalidConfigException('Failed to find how to run ' . $this->name); | |
| 151 | +            throw new InvalidConfigException('Failed to find how to run '.$this->name); | |
| 152 | 152 | } | 
| 153 | 153 | |
| 154 | 154 | return $path; | 
| @@ -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 | } | 
| @@ -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 | } | 
| @@ -49,16 +49,16 @@ | ||
| 49 | 49 |      { | 
| 50 | 50 | $path = parent::detectCommand($path); | 
| 51 | 51 | |
| 52 | - return is_executable($path) ? $path : '/usr/bin/env python ' . $path; | |
| 52 | + return is_executable($path) ? $path : '/usr/bin/env python '.$path; | |
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | 55 | public function install() | 
| 56 | 56 |      { | 
| 57 | 57 |          if ($this->installer) { | 
| 58 | -            passthru('/usr/bin/env wget ' . escapeshellarg($this->installer) . ' -O- | /usr/bin/env python', $exitcode); | |
| 58 | +            passthru('/usr/bin/env wget '.escapeshellarg($this->installer).' -O- | /usr/bin/env python', $exitcode); | |
| 59 | 59 |          } elseif ($this->download) { | 
| 60 | -            $dest = Yii::getAlias('@root/' . $this->name, false); | |
| 61 | -            passthru('/usr/bin/env wget ' . escapeshellarg($this->download) . ' -O ' . $dest, $exitcode); | |
| 60 | +            $dest = Yii::getAlias('@root/'.$this->name, false); | |
| 61 | +            passthru('/usr/bin/env wget '.escapeshellarg($this->download).' -O '.$dest, $exitcode); | |
| 62 | 62 |          } else { | 
| 63 | 63 | $args = ['install']; | 
| 64 | 64 |              if (!$_SERVER['VIRTUAL_ENV']) { | 
| @@ -56,6 +56,9 @@ | ||
| 56 | 56 | return readline($prompt); | 
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | + /** | |
| 60 | + * @param string $prompt | |
| 61 | + */ | |
| 59 | 62 | public function readpassword($prompt) | 
| 60 | 63 |      { | 
| 61 | 64 | echo $prompt; | 
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | |
| 89 | 89 | /** | 
| 90 | 90 | * Create file object. | 
| 91 | - * @param string|array $path or config | |
| 91 | + * @param string $path or config | |
| 92 | 92 | * @return File | 
| 93 | 93 | */ | 
| 94 | 94 | public static function create($path) | 
| @@ -144,6 +144,9 @@ discard block | ||
| 144 | 144 | return $type2extension[$type]; | 
| 145 | 145 | } | 
| 146 | 146 | |
| 147 | + /** | |
| 148 | + * @param string $extension | |
| 149 | + */ | |
| 147 | 150 | public function getTypeByExtension($extension) | 
| 148 | 151 |      { | 
| 149 | 152 | return isset(static::$_extension2type[$extension]) ? static::$_extension2type[$extension] : null; | 
| @@ -158,6 +161,9 @@ discard block | ||
| 158 | 161 | return ($this->goal ? $this->goal->fileType : null) ?: static::getTypeByExtension($this->_extension) ?: 'template'; | 
| 159 | 162 | } | 
| 160 | 163 | |
| 164 | + /** | |
| 165 | + * @param string $path | |
| 166 | + */ | |
| 161 | 167 | public function setPath($path) | 
| 162 | 168 |      { | 
| 163 | 169 | $path = Yii::getAlias($path); | 
| @@ -234,6 +240,9 @@ discard block | ||
| 234 | 240 | return $this->getHandler()->renderPath($this->getPath(), $this->data); | 
| 235 | 241 | } | 
| 236 | 242 | |
| 243 | + /** | |
| 244 | + * @param string $content | |
| 245 | + */ | |
| 237 | 246 | public function write($content) | 
| 238 | 247 |      { | 
| 239 | 248 | return $this->getHandler()->write($this->getPath(), $content); | 
| @@ -244,6 +253,9 @@ discard block | ||
| 244 | 253 | return $this->data = $this->getHandler()->parsePath($this->getPath(), $this->getMinimalPath()); | 
| 245 | 254 | } | 
| 246 | 255 | |
| 256 | + /** | |
| 257 | + * @return string | |
| 258 | + */ | |
| 247 | 259 | public function read() | 
| 248 | 260 |      { | 
| 249 | 261 | 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', | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 |      { | 
| 175 | 175 | $path = $this->getPath(); | 
| 176 | 176 |          if (strncmp($path, '/', 1)) { | 
| 177 | - $path = getcwd() . '/' . $path; | |
| 177 | + $path = getcwd().'/'.$path; | |
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | 180 | return $path; | 
| @@ -187,7 +187,7 @@ discard block | ||
| 187 | 187 | |
| 188 | 188 | public function setBasename($basename) | 
| 189 | 189 |      { | 
| 190 | - $this->setPath($this->_dirname . '/' . $basename); | |
| 190 | + $this->setPath($this->_dirname.'/'.$basename); | |
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | 193 | public function getBasename() | 
| @@ -197,7 +197,7 @@ discard block | ||
| 197 | 197 | |
| 198 | 198 | public function setDirname($dirname) | 
| 199 | 199 |      { | 
| 200 | - $this->setPath($dirname . '/' . $this->_basename); | |
| 200 | + $this->setPath($dirname.'/'.$this->_basename); | |
| 201 | 201 | } | 
| 202 | 202 | |
| 203 | 203 | public function getDirname() | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | |
| 208 | 208 | public function setFilename($filename) | 
| 209 | 209 |      { | 
| 210 | - $this->setPath($this->_dirname . '/' . $filename . '.' . $this->_extension); | |
| 210 | + $this->setPath($this->_dirname.'/'.$filename.'.'.$this->_extension); | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | public function getFilename() | 
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | |
| 218 | 218 | public function setExtension($extension) | 
| 219 | 219 |      { | 
| 220 | - $this->setPath($this->_dirname . '/' . $this->_filename . '.' . $extension); | |
| 220 | + $this->setPath($this->_dirname.'/'.$this->_filename.'.'.$extension); | |
| 221 | 221 | } | 
| 222 | 222 | |
| 223 | 223 | public function getExtension() | 
| @@ -268,7 +268,7 @@ discard block | ||
| 268 | 268 |      { | 
| 269 | 269 |          if (!is_object($this->_handler)) { | 
| 270 | 270 | $this->_handler = Yii::createObject([ | 
| 271 | - 'class' => 'hidev\handlers\\' . $this->getCtype() . 'Handler', | |
| 271 | + 'class' => 'hidev\handlers\\'.$this->getCtype().'Handler', | |
| 272 | 272 | 'template' => $this->template, | 
| 273 | 273 | 'goal' => $this->goal, | 
| 274 | 274 | ]); | 
| @@ -371,7 +371,7 @@ discard block | ||
| 371 | 371 | |
| 372 | 372 | public function chown($value) | 
| 373 | 373 |      { | 
| 374 | - $ownergroup = $this->getOwner() . ':' . $this->getGroup(); | |
| 374 | + $ownergroup = $this->getOwner().':'.$this->getGroup(); | |
| 375 | 375 |          if (in_array((string) $value, [$ownergroup, $this->getOwner(), $this->getUid()], true)) { | 
| 376 | 376 | return; | 
| 377 | 377 | } | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 | $level = $die ? Logger::LEVEL_ERROR : Logger::LEVEL_WARNING; | 
| 35 | -        Yii::getLogger()->log('Failed to read file: ' . $path, $level, 'file'); | |
| 35 | +        Yii::getLogger()->log('Failed to read file: '.$path, $level, 'file'); | |
| 36 | 36 | |
| 37 | 37 | return false; | 
| 38 | 38 | } | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | unlink($tmp); | 
| 65 | 65 | } | 
| 66 | 66 | } | 
| 67 | -        Yii::warning('Written file: ' . $path, 'file'); | |
| 67 | +        Yii::warning('Written file: '.$path, 'file'); | |
| 68 | 68 | |
| 69 | 69 | return true; | 
| 70 | 70 | } | 
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | $path = rtrim(trim($path), '/'); | 
| 82 | 82 |          if (!file_exists($path)) { | 
| 83 | 83 | mkdir($path, 0777, true); | 
| 84 | -            Yii::warning('Created dir:  ' . $path . '/', 'file'); | |
| 84 | +            Yii::warning('Created dir:  '.$path.'/', 'file'); | |
| 85 | 85 | |
| 86 | 86 | return true; | 
| 87 | 87 | } |