@@ -122,8 +122,8 @@ |
||
| 122 | 122 | /** |
| 123 | 123 | * Detect Laravel version |
| 124 | 124 | * |
| 125 | - * @param array $versions |
|
| 126 | - * @return type |
|
| 125 | + * @param string[] $versions |
|
| 126 | + * @return boolean |
|
| 127 | 127 | */ |
| 128 | 128 | protected function detectLaravelVersion(array $versions) |
| 129 | 129 | { |
@@ -9,20 +9,20 @@ discard block |
||
| 9 | 9 | class UnderstandLaravel5ServiceProvider extends UnderstandServiceProvider |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Indicates if loading of the provider is deferred. |
|
| 14 | - * |
|
| 15 | - * @var bool |
|
| 16 | - */ |
|
| 17 | - protected $defer = false; |
|
| 12 | + /** |
|
| 13 | + * Indicates if loading of the provider is deferred. |
|
| 14 | + * |
|
| 15 | + * @var bool |
|
| 16 | + */ |
|
| 17 | + protected $defer = false; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Bootstrap the application events. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - { |
|
| 19 | + /** |
|
| 20 | + * Bootstrap the application events. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + { |
|
| 26 | 26 | $configPath = __DIR__ . '/../../config/understand-laravel.php'; |
| 27 | 27 | $this->publishes([$configPath => config_path('understand-laravel.php')], 'config'); |
| 28 | 28 | $enabled = $this->app['config']->get('understand-laravel.enabled'); |
@@ -36,23 +36,23 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $this->listenQueryEvents(); |
| 38 | 38 | } |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Register the service provider. |
|
| 43 | - * |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public function register() |
|
| 47 | - { |
|
| 48 | - $this->registerConfig(); |
|
| 41 | + /** |
|
| 42 | + * Register the service provider. |
|
| 43 | + * |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public function register() |
|
| 47 | + { |
|
| 48 | + $this->registerConfig(); |
|
| 49 | 49 | $this->registerFieldProvider(); |
| 50 | 50 | $this->registerDataCollector(); |
| 51 | 51 | $this->registerTokenProvider(); |
| 52 | 52 | $this->registerLogger(); |
| 53 | 53 | $this->registerExceptionEncoder(); |
| 54 | 54 | $this->registerEventLoggers(); |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Register field provider |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function boot() |
| 25 | 25 | { |
| 26 | - $configPath = __DIR__ . '/../../config/understand-laravel.php'; |
|
| 26 | + $configPath = __DIR__.'/../../config/understand-laravel.php'; |
|
| 27 | 27 | $this->publishes([$configPath => config_path('understand-laravel.php')], 'config'); |
| 28 | 28 | $enabled = $this->app['config']->get('understand-laravel.enabled'); |
| 29 | 29 | |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // `\Log::info`, `\Log::debug` and NOT `\Exception` or `\Throwable` |
| 238 | - if (in_array($level, ['info', 'debug']) && ! ($message instanceof Exception || $message instanceof Throwable)) |
|
| 238 | + if (in_array($level, ['info', 'debug']) && !($message instanceof Exception || $message instanceof Throwable)) |
|
| 239 | 239 | { |
| 240 | 240 | $this->app['understand.eventLogger']->logEvent($level, $message, $context); |
| 241 | 241 | } |
| 242 | 242 | // `\Log::notice`, `\Log::warning`, `\Log::error`, `\Log::critical`, `\Log::alert`, `\Log::emergency` and `\Exception`, `\Throwable` |
| 243 | 243 | // '5.5', '5.6', '5.7', '5.8' |
| 244 | - else if ( ! $this->detectLaravelVersion(['5.0', '5.1', '5.2', '5.3', '5.4']) && isset($context['exception']) && ($context['exception'] instanceof Exception || $context['exception'] instanceof Throwable)) |
|
| 244 | + else if (!$this->detectLaravelVersion(['5.0', '5.1', '5.2', '5.3', '5.4']) && isset($context['exception']) && ($context['exception'] instanceof Exception || $context['exception'] instanceof Throwable)) |
|
| 245 | 245 | { |
| 246 | 246 | $exception = $context['exception']; |
| 247 | 247 | unset($context['exception']); |
@@ -129,8 +129,8 @@ |
||
| 129 | 129 | /** |
| 130 | 130 | * Detect Lumen version |
| 131 | 131 | * |
| 132 | - * @param array $versions |
|
| 133 | - * @return type |
|
| 132 | + * @param string[] $versions |
|
| 133 | + * @return boolean |
|
| 134 | 134 | */ |
| 135 | 135 | protected function detectLumenVersion(array $versions) |
| 136 | 136 | { |
@@ -3,11 +3,8 @@ |
||
| 3 | 3 | namespace Understand\UnderstandLaravel5; |
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | -use Illuminate\Foundation\AliasLoader; |
|
| 7 | 6 | use Illuminate\Support\Str; |
| 8 | 7 | use Understand\UnderstandLaravel5\Handlers\MonologHandler; |
| 9 | -use UnderstandMonolog\Handler\UnderstandAsyncHandler; |
|
| 10 | -use UnderstandMonolog\Handler\UnderstandSyncHandler; |
|
| 11 | 8 | |
| 12 | 9 | class UnderstandLumenServiceProvider extends UnderstandServiceProvider |
| 13 | 10 | { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | return $fieldProvider; |
| 81 | 81 | }); |
| 82 | 82 | |
| 83 | - if (! class_exists('UnderstandFieldProvider')) |
|
| 83 | + if (!class_exists('UnderstandFieldProvider')) |
|
| 84 | 84 | { |
| 85 | 85 | class_alias('Understand\UnderstandLaravel5\Facades\UnderstandFieldProvider', 'UnderstandFieldProvider'); |
| 86 | 86 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | parent::registerEventLoggers(); |
| 97 | 97 | |
| 98 | - if (! class_exists('UnderstandExceptionLogger')) |
|
| 98 | + if (!class_exists('UnderstandExceptionLogger')) |
|
| 99 | 99 | { |
| 100 | 100 | class_alias('Understand\UnderstandLaravel5\Facades\UnderstandExceptionLogger', 'UnderstandExceptionLogger'); |
| 101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | parent::registerLogger(); |
| 112 | 112 | |
| 113 | - if (! class_exists('UnderstandLogger')) |
|
| 113 | + if (!class_exists('UnderstandLogger')) |
|
| 114 | 114 | { |
| 115 | 115 | class_alias('Understand\UnderstandLaravel5\Facades\UnderstandLogger', 'UnderstandLogger'); |
| 116 | 116 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | // the illuminate.log event is raised |
| 159 | 159 | // by our MonologHandler, not by Lumen |
| 160 | - $this->app['events']->listen('illuminate.log', function ($log) |
|
| 160 | + $this->app['events']->listen('illuminate.log', function($log) |
|
| 161 | 161 | { |
| 162 | 162 | $this->handleEvent($log['level'], $log['message'], $log['context']); |
| 163 | 163 | }); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | else |
| 166 | 166 | { |
| 167 | 167 | // starting from Lumen 5.6 MessageLogged event class was introduced |
| 168 | - $this->app['events']->listen('Illuminate\Log\Events\MessageLogged', function ($log) |
|
| 168 | + $this->app['events']->listen('Illuminate\Log\Events\MessageLogged', function($log) |
|
| 169 | 169 | { |
| 170 | 170 | $this->handleEvent($log->level, $log->message, $log->context); |
| 171 | 171 | }); |
@@ -175,17 +175,17 @@ discard block |
||
| 175 | 175 | // https://github.com/illuminate/queue/commit/ce2b5518902b1bcb9ef650c41900fc8c6392eb0c |
| 176 | 176 | if ($this->app->runningInConsole()) { |
| 177 | 177 | if ($this->detectLumenVersion(['5.0', '5.1'])) { |
| 178 | - $this->app['events']->listen('illuminate.queue.after', function () { |
|
| 178 | + $this->app['events']->listen('illuminate.queue.after', function() { |
|
| 179 | 179 | $this->app['understand.tokenProvider']->generate(); |
| 180 | 180 | $this->app['understand.dataCollector']->reset(); |
| 181 | 181 | }); |
| 182 | 182 | |
| 183 | - $this->app['events']->listen('illuminate.queue.failed', function () { |
|
| 183 | + $this->app['events']->listen('illuminate.queue.failed', function() { |
|
| 184 | 184 | $this->app['understand.tokenProvider']->generate(); |
| 185 | 185 | $this->app['understand.dataCollector']->reset(); |
| 186 | 186 | }); |
| 187 | 187 | } else { |
| 188 | - $this->app['events']->listen('Illuminate\Queue\Events\JobProcessing', function () { |
|
| 188 | + $this->app['events']->listen('Illuminate\Queue\Events\JobProcessing', function() { |
|
| 189 | 189 | $this->app['understand.tokenProvider']->generate(); |
| 190 | 190 | $this->app['understand.dataCollector']->reset(); |
| 191 | 191 | }); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // `\Log::info`, `\Log::debug` and NOT `\Exception` or `\Throwable` |
| 245 | - if (in_array($level, ['info', 'debug']) && ! ($message instanceof Exception || $message instanceof Throwable)) |
|
| 245 | + if (in_array($level, ['info', 'debug']) && !($message instanceof Exception || $message instanceof Throwable)) |
|
| 246 | 246 | { |
| 247 | 247 | $this->app['understand.eventLogger']->logEvent($level, $message, $context); |
| 248 | 248 | } |
@@ -161,8 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $this->handleEvent($log['level'], $log['message'], $log['context']); |
| 163 | 163 | }); |
| 164 | - } |
|
| 165 | - else |
|
| 164 | + } else |
|
| 166 | 165 | { |
| 167 | 166 | // starting from Lumen 5.6 MessageLogged event class was introduced |
| 168 | 167 | $this->app['events']->listen('Illuminate\Log\Events\MessageLogged', function ($log) |
@@ -211,8 +210,7 @@ discard block |
||
| 211 | 210 | 'time' => $time, |
| 212 | 211 | ]); |
| 213 | 212 | }); |
| 214 | - } |
|
| 215 | - else |
|
| 213 | + } else |
|
| 216 | 214 | { |
| 217 | 215 | // https://laravel.com/api/5.3/Illuminate/Database/Events/QueryExecuted.html |
| 218 | 216 | $this->app['events']->listen('Illuminate\Database\Events\QueryExecuted', function($event) |
@@ -253,8 +251,7 @@ discard block |
||
| 253 | 251 | unset($context['exception']); |
| 254 | 252 | |
| 255 | 253 | $this->app['understand.exceptionLogger']->logError($level, $exception, $context); |
| 256 | - } |
|
| 257 | - else |
|
| 254 | + } else |
|
| 258 | 255 | { |
| 259 | 256 | $this->app['understand.exceptionLogger']->logError($level, $message, $context); |
| 260 | 257 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * @param $level |
|
| 120 | + * @param string $level |
|
| 121 | 121 | * @param $message |
| 122 | 122 | * @param $context |
| 123 | 123 | * @return bool |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * Get the services provided by the provider. |
| 138 | 138 | * |
| 139 | - * @return array |
|
| 139 | + * @return string[] |
|
| 140 | 140 | */ |
| 141 | 141 | public function provides() |
| 142 | 142 | { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | protected function registerConfig() |
| 13 | 13 | { |
| 14 | - $configPath = __DIR__ . '/../../config/understand-laravel.php'; |
|
| 14 | + $configPath = __DIR__.'/../../config/understand-laravel.php'; |
|
| 15 | 15 | $this->mergeConfigFrom($configPath, 'understand-laravel'); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | protected function registerTokenProvider() |
| 24 | 24 | { |
| 25 | - $this->app->singleton('understand.tokenProvider', function () |
|
| 25 | + $this->app->singleton('understand.tokenProvider', function() |
|
| 26 | 26 | { |
| 27 | 27 | return new TokenProvider(); |
| 28 | 28 | }); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | protected function registerDataCollector() |
| 37 | 37 | { |
| 38 | - $this->app->singleton('understand.dataCollector', function () |
|
| 38 | + $this->app->singleton('understand.dataCollector', function() |
|
| 39 | 39 | { |
| 40 | 40 | return new DataCollector(); |
| 41 | 41 | }); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | protected function registerExceptionEncoder() |
| 50 | 50 | { |
| 51 | - $this->app->bind('understand.exceptionEncoder', function () |
|
| 51 | + $this->app->bind('understand.exceptionEncoder', function() |
|
| 52 | 52 | { |
| 53 | 53 | return new ExceptionEncoder; |
| 54 | 54 | }); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return new Handlers\SyncHandler($inputToken, $apiUrl, $sslBundlePath); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - throw new \ErrorException('understand-laravel handler misconfiguration:' . $handlerType); |
|
| 116 | + throw new \ErrorException('understand-laravel handler misconfiguration:'.$handlerType); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | protected function shouldIgnoreEvent($level, $message, $context) |
| 126 | 126 | { |
| 127 | - $ignoredEventTypes = (array)$this->app['config']->get('understand-laravel.ignored_logs'); |
|
| 127 | + $ignoredEventTypes = (array) $this->app['config']->get('understand-laravel.ignored_logs'); |
|
| 128 | 128 | |
| 129 | 129 | if (!$ignoredEventTypes) { |
| 130 | 130 | return false; |
@@ -266,8 +266,7 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | // Laravel |
| 268 | 268 | return Application::VERSION; |
| 269 | - } |
|
| 270 | - else |
|
| 269 | + } else |
|
| 271 | 270 | { |
| 272 | 271 | $re = '/Lumen \((.*)\) \(.*\)/m'; |
| 273 | 272 | |
@@ -327,17 +326,14 @@ discard block |
||
| 327 | 326 | if ($value instanceof \DateTimeInterface) |
| 328 | 327 | { |
| 329 | 328 | $binding = $value->format('Y-m-d H:i:s'); |
| 330 | - } |
|
| 331 | - elseif (is_bool($value)) |
|
| 329 | + } elseif (is_bool($value)) |
|
| 332 | 330 | { |
| 333 | 331 | $binding = (int) $value; |
| 334 | - } |
|
| 335 | - else |
|
| 332 | + } else |
|
| 336 | 333 | { |
| 337 | 334 | $binding = (string)$value; |
| 338 | 335 | } |
| 339 | - } |
|
| 340 | - catch (\Exception $e) |
|
| 336 | + } catch (\Exception $e) |
|
| 341 | 337 | { |
| 342 | 338 | $binding = '[handler error]'; |
| 343 | 339 | } |
@@ -414,8 +410,7 @@ discard block |
||
| 414 | 410 | try |
| 415 | 411 | { |
| 416 | 412 | $queryString[$key] = $this->parseRequestFieldValue($key, $value); |
| 417 | - } |
|
| 418 | - catch (\Exception $e) |
|
| 413 | + } catch (\Exception $e) |
|
| 419 | 414 | { |
| 420 | 415 | $queryString[$key] = '[handler error]'; |
| 421 | 416 | } |
@@ -448,12 +443,10 @@ discard block |
||
| 448 | 443 | if (method_exists($this->request, 'json') && method_exists($this->request, 'isJson') && $this->request->isJson()) |
| 449 | 444 | { |
| 450 | 445 | $source = $this->request->json(); |
| 451 | - } |
|
| 452 | - else if ($this->request->request instanceof \IteratorAggregate) |
|
| 446 | + } else if ($this->request->request instanceof \IteratorAggregate) |
|
| 453 | 447 | { |
| 454 | 448 | $source = $this->request->request; |
| 455 | - } |
|
| 456 | - else |
|
| 449 | + } else |
|
| 457 | 450 | { |
| 458 | 451 | return; |
| 459 | 452 | } |
@@ -470,8 +463,7 @@ discard block |
||
| 470 | 463 | try |
| 471 | 464 | { |
| 472 | 465 | $postData[$key] = $this->parseRequestFieldValue($key, $value); |
| 473 | - } |
|
| 474 | - catch (\Exception $e) |
|
| 466 | + } catch (\Exception $e) |
|
| 475 | 467 | { |
| 476 | 468 | $postData[$key] = '[handler error]'; |
| 477 | 469 | } |
@@ -640,10 +632,8 @@ discard block |
||
| 640 | 632 | { |
| 641 | 633 | return $userId; |
| 642 | 634 | } |
| 643 | - } |
|
| 644 | - catch (\Throwable $e) |
|
| 645 | - {} |
|
| 646 | - catch (\Exception $e) |
|
| 635 | + } catch (\Throwable $e) |
|
| 636 | + {} catch (\Exception $e) |
|
| 647 | 637 | {} |
| 648 | 638 | |
| 649 | 639 | try |
@@ -652,10 +642,8 @@ discard block |
||
| 652 | 642 | { |
| 653 | 643 | return $user->id; |
| 654 | 644 | } |
| 655 | - } |
|
| 656 | - catch (\Throwable $e) |
|
| 657 | - {} |
|
| 658 | - catch (\Exception $e) |
|
| 645 | + } catch (\Throwable $e) |
|
| 646 | + {} catch (\Exception $e) |
|
| 659 | 647 | {} |
| 660 | 648 | |
| 661 | 649 | try |
@@ -664,10 +652,8 @@ discard block |
||
| 664 | 652 | { |
| 665 | 653 | return $user->id; |
| 666 | 654 | } |
| 667 | - } |
|
| 668 | - catch (\Throwable $e) |
|
| 669 | - {} |
|
| 670 | - catch (\Exception $e) |
|
| 655 | + } catch (\Throwable $e) |
|
| 656 | + {} catch (\Exception $e) |
|
| 671 | 657 | {} |
| 672 | 658 | } |
| 673 | 659 | |