diff --git a/.phive/phars.xml b/.phive/phars.xml index c8954a4..d311bfa 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - - + + diff --git a/phpstan.neon b/phpstan.neon index 20e6e34..71a7caa 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,9 @@ parameters: paths: - src/ - level: 5 + level: 8 bootstrapFiles: - tests/bootstrap.php + ignoreErrors: + - + identifier: missingType.iterableValue diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bf47b69..43de6f4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,37 +1,19 @@ - + + + + - - - - - - - - - - - - - - - - - - - - - @@ -47,8 +29,5 @@ - - - diff --git a/src/CakeSentryInit.php b/src/CakeSentryInit.php index 85b81c1..d3a2317 100644 --- a/src/CakeSentryInit.php +++ b/src/CakeSentryInit.php @@ -39,7 +39,7 @@ public static function init(): void } $config = self::getConfig('sentry'); - if (is_array($config) && Hash::check($config, 'dsn')) { + if ($config !== null && Hash::check($config, 'dsn')) { init($config); $event = new Event('CakeSentry.Client.afterSetup'); EventManager::instance()->dispatch($event); diff --git a/src/Database/Log/CakeSentryLog.php b/src/Database/Log/CakeSentryLog.php index d357e5c..6717016 100644 --- a/src/Database/Log/CakeSentryLog.php +++ b/src/Database/Log/CakeSentryLog.php @@ -196,8 +196,8 @@ protected function isSchemaQuery(LoggedQuery $query): bool $context = $query->getContext(); $querystring = $context['query'] ?? false; - if (!$querystring) { - $querystring = $query->jsonSerialize()['query']; + if ($querystring === '') { + $querystring = $query->jsonSerialize()['query'] ?? ''; } return // Multiple engines diff --git a/src/DebugTimer.php b/src/DebugTimer.php index 6d23205..eab6679 100644 --- a/src/DebugTimer.php +++ b/src/DebugTimer.php @@ -31,17 +31,17 @@ class DebugTimer protected static array $_timers = []; /** - * Start an benchmarking timer. + * Start a benchmarking timer. * - * @param string $name The name of the timer to start. - * @param string $message A message for your timer + * @param string|null $name The name of the timer to start. + * @param string|null $message A message for your timer * @return bool Always true */ public static function start(?string $name = null, ?string $message = null): bool { $start = microtime(true); - if (!$name) { + if ($name === null) { $named = false; $calledFrom = debug_backtrace(); $file = $calledFrom[0]['file'] ?? 'unknown file'; @@ -51,7 +51,7 @@ public static function start(?string $name = null, ?string $message = null): boo $named = true; } - if (!$message) { + if ($message === null) { $message = $name; } @@ -80,13 +80,13 @@ public static function start(?string $name = null, ?string $message = null): boo * * $name should be the same as the $name used in startTimer(). * - * @param string $name The name of the timer to end. + * @param string|null $name The name of the timer to end. * @return bool true if timer was ended, false if timer was not started. */ public static function stop(?string $name = null): bool { $end = microtime(true); - if (!$name) { + if ($name === null) { $names = array_reverse(array_keys(self::$_timers)); foreach ($names as $name) { if (!empty(self::$_timers[$name]['end'])) { @@ -110,7 +110,7 @@ public static function stop(?string $name = null): bool if (!isset(self::$_timers[$name])) { return false; } - if ($name) { + if ($name !== null) { self::$_timers[$name]['end'] = $end; } diff --git a/src/EventSpanTrait.php b/src/EventSpanTrait.php index d9a2c44..8fc1af8 100644 --- a/src/EventSpanTrait.php +++ b/src/EventSpanTrait.php @@ -30,7 +30,7 @@ public function addEventSpan(string $name, string $sentryOp, ?float $startTime = $spanContext->setDescription($name); $spanContext->setOp($sentryOp); //$spanContext->setData(); - if ($startTime && $endTime) { + if ($startTime !== null && $endTime !== null) { $spanContext->setStartTimestamp(DebugTimer::requestStartTime() + $startTime); $spanContext->setEndTimestamp(DebugTimer::requestStartTime() + $endTime); } diff --git a/src/Http/SentryClient.php b/src/Http/SentryClient.php index 5a4b151..c8bfa78 100644 --- a/src/Http/SentryClient.php +++ b/src/Http/SentryClient.php @@ -121,7 +121,7 @@ public function captureException( $event = new Event('CakeSentry.Client.beforeCapture', $this, compact('exception', 'request')); $eventManager->dispatch($event); - if ($extras) { + if ($extras !== null) { $this->hub->configureScope(function (Scope $scope) use ($extras): void { $scope->setExtras($extras); }); @@ -152,7 +152,7 @@ public function captureError( $event = new Event('CakeSentry.Client.beforeCapture', $this, compact('error', 'request')); $eventManager->dispatch($event); - if ($extras) { + if ($extras !== null) { $this->hub->configureScope(function (Scope $scope) use ($extras): void { $scope->setExtras($extras); }); @@ -163,7 +163,7 @@ public function captureError( $client = $this->hub->getClient(); if ($client) { - /** @var array $trace */ + /** @var list $trace */ $trace = $this->cleanedTrace($error->getTrace()); /** @psalm-suppress ArgumentTypeCoercion */ $stacktrace = $client->getStacktraceBuilder() @@ -196,7 +196,7 @@ public function getHub(): HubInterface * @param array> $traces * @return array> */ - private function cleanedTrace(array $traces): array + protected function cleanedTrace(array $traces): array { foreach ($traces as $key => $trace) { if (isset($trace['line']) && ($trace['line'] === '??' || $trace['line'] === '')) { diff --git a/src/QuerySpanTrait.php b/src/QuerySpanTrait.php index 80f5687..be6b012 100644 --- a/src/QuerySpanTrait.php +++ b/src/QuerySpanTrait.php @@ -50,7 +50,7 @@ public function addTransactionSpan(LoggedQuery $query, ?string $connectionName = return; } - if ($connectionName) { + if ($connectionName !== null) { /** @var \Cake\Database\Driver $driver */ $driver = ConnectionManager::get($connectionName)->getDriver(); $dialect = $driver->schemaDialect();