@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | $this->clientIp = current(swoole_get_local_ip()) ?: null; |
| 42 | 42 | } |
| 43 | 43 | if (isset($settings['pull_timeout'])) { |
| 44 | - $this->pullTimeout = (int)$settings['pull_timeout']; |
|
| 44 | + $this->pullTimeout = (int) $settings['pull_timeout']; |
|
| 45 | 45 | } |
| 46 | 46 | if (isset($settings['backup_old_env'])) { |
| 47 | - $this->backupOldEnv = (bool)$settings['backup_old_env']; |
|
| 47 | + $this->backupOldEnv = (bool) $settings['backup_old_env']; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | $settings = [ |
| 74 | 74 | 'server' => getenv('APOLLO_SERVER'), |
| 75 | 75 | 'app_id' => getenv('APOLLO_APP_ID'), |
| 76 | - 'cluster' => ($cluster = (string)getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null, |
|
| 77 | - 'namespaces' => ($namespaces = (string)getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null, |
|
| 78 | - 'client_ip' => ($clientIp = (string)getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null, |
|
| 79 | - 'pull_timeout' => ($pullTimeout = (int)getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null, |
|
| 80 | - 'backup_old_env' => ($backupOldEnv = (bool)getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null, |
|
| 76 | + 'cluster' => ($cluster = (string) getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null, |
|
| 77 | + 'namespaces' => ($namespaces = (string) getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null, |
|
| 78 | + 'client_ip' => ($clientIp = (string) getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null, |
|
| 79 | + 'pull_timeout' => ($pullTimeout = (int) getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null, |
|
| 80 | + 'backup_old_env' => ($backupOldEnv = (bool) getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null, |
|
| 81 | 81 | ]; |
| 82 | 82 | return new static($settings); |
| 83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | 'cluster' => isset($options['apollo-cluster']) && $options['apollo-cluster'] !== '' ? $options['apollo-cluster'] : null, |
| 94 | 94 | 'namespaces' => !empty($options['apollo-namespaces']) ? $options['apollo-namespaces'] : null, |
| 95 | 95 | 'client_ip' => isset($options['apollo-client-ip']) && $options['apollo-client-ip'] !== '' ? $options['apollo-client-ip'] : null, |
| 96 | - 'pull_timeout' => isset($options['apollo-pull-timeout']) ? (int)$options['apollo-pull-timeout'] : null, |
|
| 97 | - 'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool)$options['apollo-backup-old-env'] : null, |
|
| 96 | + 'pull_timeout' => isset($options['apollo-pull-timeout']) ? (int) $options['apollo-pull-timeout'] : null, |
|
| 97 | + 'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool) $options['apollo-backup-old-env'] : null, |
|
| 98 | 98 | ]; |
| 99 | 99 | return new static($settings); |
| 100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $configs = []; |
| 117 | 117 | $uri = sprintf('%s/configs/%s/%s/', $this->server, $this->appId, $this->cluster); |
| 118 | 118 | foreach ($namespaces as $namespace) { |
| 119 | - $url = $uri . $namespace . '?' . http_build_query([ |
|
| 119 | + $url = $uri.$namespace.'?'.http_build_query([ |
|
| 120 | 120 | 'releaseKey' => $withReleaseKey && isset($this->releaseKeys[$namespace]) ? $this->releaseKeys[$namespace] : null, |
| 121 | 121 | 'ip' => $this->clientIp, |
| 122 | 122 | ]); |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | $all = $this->pullAll(false, $options); |
| 147 | 147 | if (count($all) !== count($this->namespaces)) { |
| 148 | 148 | $lackNamespaces = array_diff($this->namespaces, array_keys($all)); |
| 149 | - throw new \RuntimeException('Missing Apollo configurations for namespaces ' . implode(',', $lackNamespaces)); |
|
| 149 | + throw new \RuntimeException('Missing Apollo configurations for namespaces '.implode(',', $lackNamespaces)); |
|
| 150 | 150 | } |
| 151 | 151 | $configs = []; |
| 152 | 152 | foreach ($all as $namespace => $config) { |
| 153 | - $configs[] = '# Namespace: ' . $config['namespaceName']; |
|
| 153 | + $configs[] = '# Namespace: '.$config['namespaceName']; |
|
| 154 | 154 | ksort($config['configurations']); |
| 155 | 155 | foreach ($config['configurations'] as $key => $value) { |
| 156 | 156 | $configs[] = sprintf('%s=%s', $key, $value); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | throw new \RuntimeException('Empty Apollo configuration list'); |
| 161 | 161 | } |
| 162 | 162 | if ($this->backupOldEnv && file_exists($filepath)) { |
| 163 | - rename($filepath, $filepath . '.' . date('YmdHis')); |
|
| 163 | + rename($filepath, $filepath.'.'.date('YmdHis')); |
|
| 164 | 164 | } |
| 165 | 165 | $fileContent = implode(PHP_EOL, $configs); |
| 166 | 166 | if (Context::inCoroutine()) { |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | if (!empty($this->notifications) && current($this->notifications)['notificationId'] !== -1) { // Ignore the first pull |
| 201 | 201 | $callback($notifications); |
| 202 | 202 | } |
| 203 | - array_walk($notifications, function (&$notification) { |
|
| 203 | + array_walk($notifications, function(&$notification) { |
|
| 204 | 204 | unset($notification['messages']); |
| 205 | 205 | }); |
| 206 | 206 | $this->notifications = array_merge($this->notifications, array_column($notifications, null, 'namespaceName')); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function interval() |
| 17 | 17 | { |
| 18 | - return 60 * 1000;// Run every 1 minute |
|
| 18 | + return 60 * 1000; // Run every 1 minute |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function isImmediate() |
@@ -9,14 +9,14 @@ |
||
| 9 | 9 | public function boot() |
| 10 | 10 | { |
| 11 | 11 | $this->publishes([ |
| 12 | - __DIR__ . '/../../config/laravels.php' => base_path('config/laravels.php'), |
|
| 12 | + __DIR__.'/../../config/laravels.php' => base_path('config/laravels.php'), |
|
| 13 | 13 | ]); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function register() |
| 17 | 17 | { |
| 18 | 18 | $this->mergeConfigFrom( |
| 19 | - __DIR__ . '/../../config/laravels.php', 'laravels' |
|
| 19 | + __DIR__.'/../../config/laravels.php', 'laravels' |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | $this->commands([ |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | { |
| 77 | 77 | $this->cleaners = array_unique(array_merge($cleaners, $this->cleaners)); |
| 78 | 78 | foreach ($this->cleaners as $class) { |
| 79 | - $this->currentApp->singleton($class, function () use ($class) { |
|
| 79 | + $this->currentApp->singleton($class, function() use ($class) { |
|
| 80 | 80 | $cleaner = new $class($this->currentApp, $this->snapshotApp); |
| 81 | 81 | if (!($cleaner instanceof BaseCleaner)) { |
| 82 | 82 | throw new \InvalidArgumentException(sprintf( |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | private function allControllerProperties() |
| 61 | 61 | { |
| 62 | 62 | $controllers = $this->allControllers(); |
| 63 | - array_walk($controllers, function (&$properties, $controller) { |
|
| 63 | + array_walk($controllers, function(&$properties, $controller) { |
|
| 64 | 64 | $properties = []; |
| 65 | 65 | // Get parent's properties |
| 66 | 66 | $parent = get_parent_class($controller); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function addFileType($type) |
| 29 | 29 | { |
| 30 | - $type = '.' . trim($type, '.'); |
|
| 30 | + $type = '.'.trim($type, '.'); |
|
| 31 | 31 | $this->fileTypes[$type] = true; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function isExcluded($path) |
| 55 | 55 | { |
| 56 | 56 | foreach ($this->excludedDirs as $excludedDir) { |
| 57 | - if ($excludedDir === $path || strpos($path, $excludedDir . '/') === 0) { |
|
| 57 | + if ($excludedDir === $path || strpos($path, $excludedDir.'/') === 0) { |
|
| 58 | 58 | return true; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | if ($file === '.' || $file === '..' || $this->isExcluded($file)) { |
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | - $file = $path . DIRECTORY_SEPARATOR . $file; |
|
| 91 | + $file = $path.DIRECTORY_SEPARATOR.$file; |
|
| 92 | 92 | if (is_dir($file)) { |
| 93 | 93 | $this->_watch($file); |
| 94 | 94 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | public function start() |
| 124 | 124 | { |
| 125 | - Event::add($this->fd, function ($fp) { |
|
| 125 | + Event::add($this->fd, function($fp) { |
|
| 126 | 126 | $events = inotify_read($fp); |
| 127 | 127 | foreach ($events as $event) { |
| 128 | 128 | if ($event['mask'] == IN_IGNORED) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - Timer::after(100, function () use ($event) { |
|
| 141 | + Timer::after(100, function() use ($event) { |
|
| 142 | 142 | call_user_func_array($this->watchHandler, [$event]); |
| 143 | 143 | $this->doing = false; |
| 144 | 144 | }); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if ($len > $this->chunkLimit) { |
| 38 | - for ($offset = 0, $limit = (int)(0.6 * $this->chunkLimit); $offset < $len; $offset += $limit) { |
|
| 38 | + for ($offset = 0, $limit = (int) (0.6 * $this->chunkLimit); $offset < $len; $offset += $limit) { |
|
| 39 | 39 | $chunk = substr($content, $offset, $limit); |
| 40 | 40 | $this->swooleResponse->write($chunk); |
| 41 | 41 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | if ($deleteFile) { |
| 48 | 48 | $fp = fopen($path, 'rb'); |
| 49 | 49 | |
| 50 | - for ($offset = 0, $limit = (int)(0.99 * $this->chunkLimit); $offset < $size; $offset += $limit) { |
|
| 50 | + for ($offset = 0, $limit = (int) (0.99 * $this->chunkLimit); $offset < $size; $offset += $limit) { |
|
| 51 | 51 | fseek($fp, $offset, SEEK_SET); |
| 52 | 52 | $chunk = fread($fp, $limit); |
| 53 | 53 | $this->swooleResponse->write($chunk); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | if ($delay < 0) { |
| 29 | 29 | throw new \InvalidArgumentException('The delay must be greater than or equal to 0'); |
| 30 | 30 | } |
| 31 | - $this->delay = (int)$delay; |
|
| 31 | + $this->delay = (int) $delay; |
|
| 32 | 32 | return $this; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if ($tries < 1) { |
| 52 | 52 | throw new \InvalidArgumentException('The number of attempts must be greater than or equal to 1'); |
| 53 | 53 | } |
| 54 | - $this->tries = (int)$tries; |
|
| 54 | + $this->tries = (int) $tries; |
|
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -71,19 +71,19 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | protected function task($task) |
| 73 | 73 | { |
| 74 | - $deliver = function () use ($task) { |
|
| 74 | + $deliver = function() use ($task) { |
|
| 75 | 75 | /**@var \Swoole\Http\Server $swoole */ |
| 76 | 76 | $swoole = app('swoole'); |
| 77 | 77 | // The worker_id of timer process is -1 |
| 78 | 78 | if ($swoole->worker_id === -1 || $swoole->taskworker) { |
| 79 | - $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0; |
|
| 79 | + $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int) $swoole->setting['task_worker_num'] : 0; |
|
| 80 | 80 | if ($taskWorkerNum < 2) { |
| 81 | 81 | throw new \InvalidArgumentException('LaravelS: async task needs to set task_worker_num >= 2'); |
| 82 | 82 | } |
| 83 | 83 | $workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0; |
| 84 | 84 | $totalNum = $workerNum + $taskWorkerNum; |
| 85 | 85 | |
| 86 | - $getAvailableId = function ($startId, $endId, $excludeId) { |
|
| 86 | + $getAvailableId = function($startId, $endId, $excludeId) { |
|
| 87 | 87 | $ids = range($startId, $endId); |
| 88 | 88 | $ids = array_flip($ids); |
| 89 | 89 | unset($ids[$excludeId]); |