| Conditions | 15 |
| Paths | 308 |
| Total Lines | 60 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 75 | protected function start() |
||
| 76 | { |
||
| 77 | $this->outputLogo(); |
||
| 78 | |||
| 79 | $svrConf = config('laravels'); |
||
| 80 | $basePath = array_get($svrConf, 'laravel_base_path', base_path()); |
||
| 81 | |||
| 82 | if (empty($svrConf['swoole']['document_root'])) { |
||
| 83 | $svrConf['swoole']['document_root'] = $basePath . '/public'; |
||
| 84 | } |
||
| 85 | if (empty($svrConf['process_prefix'])) { |
||
| 86 | $svrConf['process_prefix'] = $basePath; |
||
| 87 | } |
||
| 88 | if (!empty($svrConf['events'])) { |
||
| 89 | if (empty($svrConf['swoole']['task_worker_num']) || $svrConf['swoole']['task_worker_num'] <= 0) { |
||
| 90 | $this->error('LaravelS: Asynchronous event listening needs to set task_worker_num > 0'); |
||
| 91 | return; |
||
| 92 | } |
||
| 93 | } |
||
| 94 | if ($this->option('daemonize')) { |
||
| 95 | $svrConf['swoole']['daemonize'] = true; |
||
| 96 | } |
||
| 97 | |||
| 98 | $laravelConf = [ |
||
| 99 | 'root_path' => $basePath, |
||
| 100 | 'static_path' => $svrConf['swoole']['document_root'], |
||
| 101 | 'register_providers' => array_unique((array)array_get($svrConf, 'register_providers', [])), |
||
| 102 | 'is_lumen' => $this->isLumen, |
||
| 103 | '_SERVER' => $_SERVER, |
||
| 104 | '_ENV' => $_ENV, |
||
| 105 | ]; |
||
| 106 | |||
| 107 | if (file_exists($svrConf['swoole']['pid_file'])) { |
||
| 108 | $pid = (int)file_get_contents($svrConf['swoole']['pid_file']); |
||
| 109 | if ($pid > 0 && $this->killProcess($pid, 0)) { |
||
| 110 | $this->warn(sprintf('LaravelS: PID[%s] is already running at %s:%s.', $pid, $svrConf['listen_ip'], $svrConf['listen_port'])); |
||
| 111 | return; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | // Implements gracefully reload, avoid including laravel's files before worker start |
||
| 116 | $cmd = sprintf('%s %s/../GoLaravelS.php', PHP_BINARY, __DIR__); |
||
| 117 | $ret = $this->popen($cmd, json_encode(compact('svrConf', 'laravelConf'))); |
||
| 118 | if ($ret === false) { |
||
| 119 | $this->error('LaravelS: popen ' . $cmd . ' failed'); |
||
| 120 | return; |
||
| 121 | } |
||
| 122 | |||
| 123 | $pidFile = empty($svrConf['swoole']['pid_file']) ? storage_path('laravels.pid') : $svrConf['swoole']['pid_file']; |
||
| 124 | |||
| 125 | // Make sure that master process started |
||
| 126 | $time = 0; |
||
| 127 | while (!file_exists($pidFile) && $time <= 20) { |
||
| 128 | usleep(100000); |
||
| 129 | $time++; |
||
| 130 | } |
||
| 131 | if (file_exists($pidFile)) { |
||
| 132 | $this->info(sprintf('LaravelS: PID[%s] is running at %s:%s.', file_get_contents($pidFile), $svrConf['listen_ip'], $svrConf['listen_port'])); |
||
| 133 | } else { |
||
| 134 | $this->error(sprintf('LaravelS: PID file[%s] does not exist.', $pidFile)); |
||
| 135 | } |
||
| 262 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.