| @@ -72,6 +72,9 @@ | ||
| 72 | 72 | return false; | 
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | + /** | |
| 76 | + * @param string $id | |
| 77 | + */ | |
| 75 | 78 | public function getGoal($id) | 
| 76 | 79 |      { | 
| 77 | 80 | return Yii::$app->createControllerById($id); | 
| @@ -122,6 +122,9 @@ discard block | ||
| 122 | 122 | return $type2extension[$type]; | 
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | + /** | |
| 126 | + * @param string $extension | |
| 127 | + */ | |
| 125 | 128 | public function getTypeByExtension($extension) | 
| 126 | 129 |      { | 
| 127 | 130 | return static::$_extension2type[$extension]; | 
| @@ -132,6 +135,9 @@ discard block | ||
| 132 | 135 | return ($this->goal ? $this->goal->fileType : null) ?: static::getTypeByExtension($this->_extension) ?: 'template'; | 
| 133 | 136 | } | 
| 134 | 137 | |
| 138 | + /** | |
| 139 | + * @param string $path | |
| 140 | + */ | |
| 135 | 141 | public function setPath($path) | 
| 136 | 142 |      { | 
| 137 | 143 | $path = Yii::getAlias($path); | 
| @@ -208,6 +214,9 @@ discard block | ||
| 208 | 214 | return $this->handler->renderPath($this->path, $this->data); | 
| 209 | 215 | } | 
| 210 | 216 | |
| 217 | + /** | |
| 218 | + * @param string $content | |
| 219 | + */ | |
| 211 | 220 | public function write($content) | 
| 212 | 221 |      { | 
| 213 | 222 | return $this->handler->write($this->path, $content); | 
| @@ -218,6 +227,9 @@ discard block | ||
| 218 | 227 | return $this->data = $this->handler->parsePath($this->path, $this->minimalPath); | 
| 219 | 228 | } | 
| 220 | 229 | |
| 230 | + /** | |
| 231 | + * @return string | |
| 232 | + */ | |
| 221 | 233 | public function read() | 
| 222 | 234 |      { | 
| 223 | 235 | return $this->handler->read($this->path); | 
| @@ -109,7 +109,7 @@ discard block | ||
| 109 | 109 | */ | 
| 110 | 110 | protected static $_extension2type = [ | 
| 111 | 111 | 'json' => 'json', | 
| 112 | - 'yml' => 'yaml', /// first one is preferred | |
| 112 | + 'yml' => 'yaml', /// first one is preferred | |
| 113 | 113 | 'yaml' => 'yaml', | 
| 114 | 114 | 'xml' => 'xml', | 
| 115 | 115 | 'xml.dist' => 'xml', | 
| @@ -158,7 +158,7 @@ discard block | ||
| 158 | 158 | |
| 159 | 159 | public function setBasename($basename) | 
| 160 | 160 |      { | 
| 161 | - $this->setPath($this->_dirname . '/' . $basename); | |
| 161 | + $this->setPath($this->_dirname.'/'.$basename); | |
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | public function getBasename() | 
| @@ -168,7 +168,7 @@ discard block | ||
| 168 | 168 | |
| 169 | 169 | public function setDirname($dirname) | 
| 170 | 170 |      { | 
| 171 | - $this->setPath($dirname . '/' . $this->_basename); | |
| 171 | + $this->setPath($dirname.'/'.$this->_basename); | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | public function getDirname() | 
| @@ -178,7 +178,7 @@ discard block | ||
| 178 | 178 | |
| 179 | 179 | public function setFilename($filename) | 
| 180 | 180 |      { | 
| 181 | - $this->setPath($this->_dirname . '/' . $filename . '.' . $this->_extension); | |
| 181 | + $this->setPath($this->_dirname.'/'.$filename.'.'.$this->_extension); | |
| 182 | 182 | } | 
| 183 | 183 | |
| 184 | 184 | public function getFilename() | 
| @@ -188,7 +188,7 @@ discard block | ||
| 188 | 188 | |
| 189 | 189 | public function setExtension($extension) | 
| 190 | 190 |      { | 
| 191 | - $this->setPath($this->_dirname . '/' . $this->_filename . '.' . $extension); | |
| 191 | + $this->setPath($this->_dirname.'/'.$this->_filename.'.'.$extension); | |
| 192 | 192 | } | 
| 193 | 193 | |
| 194 | 194 | public function getExtension() | 
| @@ -239,7 +239,7 @@ discard block | ||
| 239 | 239 |      { | 
| 240 | 240 |          if (!is_object($this->_handler)) { | 
| 241 | 241 | $this->_handler = Yii::createObject([ | 
| 242 | - 'class' => 'hidev\handlers\\' . $this->getCtype() . 'Handler', | |
| 242 | + 'class' => 'hidev\handlers\\'.$this->getCtype().'Handler', | |
| 243 | 243 | 'template' => $this->template, | 
| 244 | 244 | 'goal' => $this->goal, | 
| 245 | 245 | ]); | 
| @@ -336,7 +336,7 @@ discard block | ||
| 336 | 336 | |
| 337 | 337 | public function chown($value) | 
| 338 | 338 |      { | 
| 339 | - $ownergroup = $this->getOwner() . ':' . $this->getGroup(); | |
| 339 | + $ownergroup = $this->getOwner().':'.$this->getGroup(); | |
| 340 | 340 |          if (in_array($value, [$ownergroup, $this->getOwner(), $this->getUid()], false)) { | 
| 341 | 341 | return; | 
| 342 | 342 | } | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | /** | 
| 114 | 114 | * Action to check if repo exists. | 
| 115 | 115 | * @param string $repo full name vendor/package defaults to this repo name | 
| 116 | - * @return int exit code | |
| 116 | + * @return boolean exit code | |
| 117 | 117 | */ | 
| 118 | 118 | public function actionExists($repo = null) | 
| 119 | 119 |      { | 
| @@ -160,6 +160,10 @@ discard block | ||
| 160 | 160 | return 0; | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | + /** | |
| 164 | + * @param string $method | |
| 165 | + * @param string $path | |
| 166 | + */ | |
| 163 | 167 | public function request($method, $path, $data) | 
| 164 | 168 |      { | 
| 165 | 169 | $url = 'https://api.github.com' . $path; | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | |
| 35 | 35 | public function getFull_name() | 
| 36 | 36 |      { | 
| 37 | - return $this->getVendor() . '/' . $this->getName(); | |
| 37 | + return $this->getVendor().'/'.$this->getName(); | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | public function setFullName($value) | 
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | */ | 
| 96 | 96 | public function actionCreate() | 
| 97 | 97 |      { | 
| 98 | -        $res = $this->request('POST', '/orgs/' . $this->getVendor() . '/repos', [ | |
| 98 | +        $res = $this->request('POST', '/orgs/'.$this->getVendor().'/repos', [ | |
| 99 | 99 | 'name' => $this->getName(), | 
| 100 | 100 | 'description' => $this->getDescription(), | 
| 101 | 101 | ]); | 
| @@ -114,7 +114,7 @@ discard block | ||
| 114 | 114 | */ | 
| 115 | 115 | public function actionClone($repo) | 
| 116 | 116 |      { | 
| 117 | -        return $this->passthru('git', ['clone', '[email protected]:' . $repo]); | |
| 117 | +        return $this->passthru('git', ['clone', '[email protected]:'.$repo]); | |
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | 120 | /** | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | */ | 
| 135 | 135 | public static function exists($repo) | 
| 136 | 136 |      { | 
| 137 | -        return !static::exec('git', ['ls-remote', '[email protected]:' . $repo], true); | |
| 137 | +        return !static::exec('git', ['ls-remote', '[email protected]:'.$repo], true); | |
| 138 | 138 | } | 
| 139 | 139 | |
| 140 | 140 | public function actionRelease($version = null) | 
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | return $wait; | 
| 149 | 149 | } | 
| 150 | 150 | |
| 151 | -        return $this->request('POST', '/repos/' . $this->getFull_name() . '/releases', [ | |
| 151 | +        return $this->request('POST', '/repos/'.$this->getFull_name().'/releases', [ | |
| 152 | 152 | 'tag_name' => $version, | 
| 153 | 153 | 'name' => $version, | 
| 154 | 154 | 'body' => $notes, | 
| @@ -169,9 +169,9 @@ discard block | ||
| 169 | 169 | |
| 170 | 170 | public function request($method, $path, $data) | 
| 171 | 171 |      { | 
| 172 | - $url = 'https://api.github.com' . $path; | |
| 172 | + $url = 'https://api.github.com'.$path; | |
| 173 | 173 | |
| 174 | -        return $this->passthru('curl', ['-X', $method, '-H', 'Authorization: token ' . $this->getToken(), '--data', Json::encode($data), $url]); | |
| 174 | +        return $this->passthru('curl', ['-X', $method, '-H', 'Authorization: token '.$this->getToken(), '--data', Json::encode($data), $url]); | |
| 175 | 175 | } | 
| 176 | 176 | |
| 177 | 177 | public function findToken() | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | * | 
| 92 | 92 | * @param mixed $data | 
| 93 | 93 | * | 
| 94 | - * @return string file content | |
| 94 | + * @return boolean file content | |
| 95 | 95 | */ | 
| 96 | 96 | public function renderPath($path, $data) | 
| 97 | 97 |      { | 
| @@ -156,7 +156,7 @@ discard block | ||
| 156 | 156 | * Read file into a string or array. | 
| 157 | 157 | * @param string $path | 
| 158 | 158 | * @param bool $asArray | 
| 159 | - * @return string|array | |
| 159 | + * @return string | |
| 160 | 160 | */ | 
| 161 | 161 | public function read($path, $asArray = false) | 
| 162 | 162 |      { | 
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | public function read($path, $asArray = false) | 
| 147 | 147 |      { | 
| 148 | 148 |          if (file_exists($path)) { | 
| 149 | -            Yii::info('Read file: ' . $path, 'file'); | |
| 149 | +            Yii::info('Read file: '.$path, 'file'); | |
| 150 | 150 | |
| 151 | 151 | return $asArray ? file($path) : file_get_contents($path); | 
| 152 | 152 |          } else { | 
| 153 | -            Yii::error('Couldn\'t read file: ' . $path, 'file'); | |
| 153 | +            Yii::error('Couldn\'t read file: '.$path, 'file'); | |
| 154 | 154 | |
| 155 | 155 | return; | 
| 156 | 156 | } | 
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | /** | 
| 51 | - * @return int|Response exit code | |
| 51 | + * @return null|integer exit code | |
| 52 | 52 | */ | 
| 53 | 53 | public function actionMake() | 
| 54 | 54 |      { | 
| @@ -142,7 +142,7 @@ discard block | ||
| 142 | 142 | /** | 
| 143 | 143 | * Is response NOT Ok. | 
| 144 | 144 | * @param Response|int $res | 
| 145 | - * @return bool | |
| 145 | + * @return integer | |
| 146 | 146 | */ | 
| 147 | 147 | public static function isNotOk($res) | 
| 148 | 148 |      { | 
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | |
| 152 | 152 | /** | 
| 153 | 153 | * Is response Ok. | 
| 154 | - * @param Response|int $res | |
| 154 | + * @param integer $res | |
| 155 | 155 | * @return bool | 
| 156 | 156 | */ | 
| 157 | 157 | public static function isOk($res) | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | * Runs list of actions. | 
| 164 | 164 | * TODO: think to redo with runRequests. | 
| 165 | 165 | * @param null|string|array $actions | 
| 166 | - * @return int|Response exit code | |
| 166 | + * @return null|integer exit code | |
| 167 | 167 | */ | 
| 168 | 168 | public function runActions($actions) | 
| 169 | 169 |      { | 
| @@ -240,6 +240,9 @@ discard block | ||
| 240 | 240 | return readline($prompt); | 
| 241 | 241 | } | 
| 242 | 242 | |
| 243 | + /** | |
| 244 | + * @param string $prompt | |
| 245 | + */ | |
| 243 | 246 | public function readpassword($prompt) | 
| 244 | 247 |      { | 
| 245 | 248 | echo $prompt; | 
| @@ -250,6 +253,9 @@ discard block | ||
| 250 | 253 | return $password; | 
| 251 | 254 | } | 
| 252 | 255 | |
| 256 | + /** | |
| 257 | + * @param string $id | |
| 258 | + */ | |
| 253 | 259 | public static function takeGoal($id) | 
| 254 | 260 |      { | 
| 255 | 261 |          return Yii::$app->get('config')->getGoal($id); | 
| @@ -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 | } | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 |      { | 
| 38 | 38 | $items = []; | 
| 39 | 39 |          foreach ($this->takeGoal('binaries')->keys() as $name) { | 
| 40 | - $items[$name . '.phar'] = 'PHARs'; | |
| 40 | + $items[$name.'.phar'] = 'PHARs'; | |
| 41 | 41 | } | 
| 42 | 42 | unset($items['git.phar']); | 
| 43 | 43 | $this->takeVcs()->setIgnore($items); | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 |          $cur = (integer) date('Y'); | 
| 35 | 35 | $old = (integer) $this->year; | 
| 36 | 36 | |
| 37 | - return ($old && $old < $cur ? $this->year . '-' : '') . $cur; | |
| 37 | + return ($old && $old < $cur ? $this->year.'-' : '').$cur; | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | public function getYear() | 
| @@ -49,12 +49,12 @@ discard block | ||
| 49 | 49 | |
| 50 | 50 | public function getIssues() | 
| 51 | 51 |      { | 
| 52 | -        return $this->getItem('issues') ?: ($this->source . '/issues'); | |
| 52 | +        return $this->getItem('issues') ?: ($this->source.'/issues'); | |
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | 55 | public function getWiki() | 
| 56 | 56 |      { | 
| 57 | -        return $this->getItem('wiki') ?: ($this->source . '/wiki'); | |
| 57 | +        return $this->getItem('wiki') ?: ($this->source.'/wiki'); | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | public function getKeywords() | 
| @@ -64,12 +64,12 @@ discard block | ||
| 64 | 64 | |
| 65 | 65 | public function getFullName() | 
| 66 | 66 |      { | 
| 67 | -        return $this->getItem('fullName') ?: ($this->takeVendor()->name . '/' . $this->name); | |
| 67 | +        return $this->getItem('fullName') ?: ($this->takeVendor()->name.'/'.$this->name); | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | public function getSource() | 
| 71 | 71 |      { | 
| 72 | -        return $this->getItem('source') ?: ('https://github.com/' . $this->takeGoal('github')->full_name); | |
| 72 | +        return $this->getItem('source') ?: ('https://github.com/'.$this->takeGoal('github')->full_name); | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | public function getVersion() | 
| @@ -84,7 +84,7 @@ discard block | ||
| 84 | 84 | |
| 85 | 85 | public static function defaultNamespace($vendor, $package) | 
| 86 | 86 |      { | 
| 87 | -        return preg_replace('/[^a-zA-Z0-9\\\\]+/', '', $vendor . strtr("-$package", '-', '\\')); | |
| 87 | +        return preg_replace('/[^a-zA-Z0-9\\\\]+/', '', $vendor.strtr("-$package", '-', '\\')); | |
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | 90 | public function getSrc() | 
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | |
| 97 | 97 | public function getHomepage() | 
| 98 | 98 |      { | 
| 99 | -        return $this->getItem('homepage') ?: ($this->isDomain() ? 'http://' . $this->name . '/' : $this->getSource()); | |
| 99 | +        return $this->getItem('homepage') ?: ($this->isDomain() ? 'http://'.$this->name.'/' : $this->getSource()); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | public function getForum() | 
| @@ -131,7 +131,7 @@ discard block | ||
| 131 | 131 | |
| 132 | 132 | public function getRepositoryUrl($file) | 
| 133 | 133 |      { | 
| 134 | - return 'https://github.com/' . $this->getFullName() . '/blob/master/' . $file; | |
| 134 | + return 'https://github.com/'.$this->getFullName().'/blob/master/'.$file; | |
| 135 | 135 | } | 
| 136 | 136 | public function getAuthors() | 
| 137 | 137 |      { |