diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..b9cd55d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,14 @@
+; This file is for unifying the coding style for different editors and IDEs.
+; More information at https://editorconfig.org
+
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.neon]
+indent_style = tab
diff --git a/.gitattributes b/.gitattributes
index 1ca592c..4eefc44 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,6 @@
+# Set the default behavior for all files.
+* text=auto
+
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
diff --git a/README.md b/README.md
index 05c889a..4e8bc8a 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ CakePHP integration for Sentry.
- PHP 8.1+
- CakePHP 5+
- and a [Sentry](https://sentry.io) account
- - if you use self hosted sentry make sure you are on at least version `>= v20.6.0`
+ - if you use self-hosted sentry make sure you are on at least version `>= v20.6.0`
## Version table
| | PHP | CakePHP | self-hosted Sentry |
@@ -82,7 +82,7 @@ You can filter out noisy exceptions which should not be debugged further.
Also see [CakePHP Cookbook](https://book.cakephp.org/4/en/development/errors.html#error-exception-configuration)
### Set Options
-Everything inside the `'Sentry'` configuration key will be passed to `\Sentry\init()`.
+Everything inside the `'Sentry'` configuration key will be passed to `\Sentry\init()`.
Please check Sentry's official documentation on [about configuration](https://docs.sentry.io/error-reporting/configuration/?platform=php) and [about php-sdk's configuraion](https://docs.sentry.io/platforms/php/#php-specific-options).
CakeSentry also provides custom event hooks to set dynamic values.
@@ -101,7 +101,7 @@ use Cake\Event\EventListenerInterface;
class SentryOptionsContext implements EventListenerInterface
{
- public function implementedEvents(): array
+ public function implementedEvents(): array
{
return [
'CakeSentry.Client.afterSetup' => 'setServerContext',
diff --git a/composer.json b/composer.json
index b56dabf..a6e6fc7 100644
--- a/composer.json
+++ b/composer.json
@@ -19,8 +19,8 @@
},
"scripts": {
"test": "phpunit",
- "cs-check": "phpcs --colors -p src tests",
- "cs-fix": "phpcbf --colors -p src tests",
+ "cs-check": "phpcs --colors -p src/ tests/",
+ "cs-fix": "phpcbf --colors -p src/ tests/",
"phpstan": "tools/phpstan analyse",
"psalm": "tools/psalm --show-info=false",
"stan": [
diff --git a/phpstan.neon b/phpstan.neon
index 8c2eb0d..82a5f40 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,7 +1,7 @@
parameters:
- paths:
- - src
- - tests/TestCase
- level: 5
- bootstrapFiles:
- - tests/bootstrap.php
+ paths:
+ - src/
+ level: 5
+ checkMissingIterableValueType: false
+ bootstrapFiles:
+ - tests/bootstrap.php
diff --git a/phpunit.xml b/phpunit.xml
index 1c2afad..5707d1d 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -10,14 +10,14 @@
- ./tests/TestCase/
+ tests/TestCase/
diff --git a/src/Http/SentryClient.php b/src/Http/SentryClient.php
index 6ed1632..5a4b151 100644
--- a/src/Http/SentryClient.php
+++ b/src/Http/SentryClient.php
@@ -57,7 +57,9 @@ protected function getQueryLoggers(): void
if ($connection->configName() === 'debug_kit') {
continue;
}
- $logger = $connection->getDriver()->getLogger();
+ /** @var \Cake\Database\Driver $driver */
+ $driver = $connection->getDriver();
+ $logger = $driver->getLogger();
if ($logger instanceof CakeSentryLog) {
$logger->setIncludeSchema($includeSchemaReflection);
@@ -161,6 +163,7 @@ public function captureError(
$client = $this->hub->getClient();
if ($client) {
+ /** @var array $trace */
$trace = $this->cleanedTrace($error->getTrace());
/** @psalm-suppress ArgumentTypeCoercion */
$stacktrace = $client->getStacktraceBuilder()
diff --git a/src/Middleware/CakeSentryPerformanceMiddleware.php b/src/Middleware/CakeSentryPerformanceMiddleware.php
index 2dd8aef..40cf675 100644
--- a/src/Middleware/CakeSentryPerformanceMiddleware.php
+++ b/src/Middleware/CakeSentryPerformanceMiddleware.php
@@ -110,9 +110,10 @@ protected function addQueryData(): void
continue;
}
$logger = null;
+ /** @var \Cake\Database\Driver $driver */
$driver = $connection->getDriver();
$driverConfig = $driver->config();
- if ($driverConfig['sentryLog']) {
+ if ($driverConfig['sentryLog'] ?? false) {
$logger = $driver->getLogger();
if ($logger instanceof CakeSentryLog) {
$logger->setPerformanceMonitoring(true);
diff --git a/src/Middleware/CakeSentryQueryMiddleware.php b/src/Middleware/CakeSentryQueryMiddleware.php
index f47f9ba..f62c36c 100644
--- a/src/Middleware/CakeSentryQueryMiddleware.php
+++ b/src/Middleware/CakeSentryQueryMiddleware.php
@@ -57,9 +57,10 @@ protected function enableQueryLogging(): void
continue;
}
$logger = null;
+ /** @var \Cake\Database\Driver $driver */
$driver = $connection->getDriver();
$driverConfig = $driver->config();
- if ($driverConfig['sentryLog']) {
+ if ($driverConfig['sentryLog'] ?? false) {
$logger = $driver->getLogger();
}
diff --git a/src/QuerySpanTrait.php b/src/QuerySpanTrait.php
index a7cb61a..26963eb 100644
--- a/src/QuerySpanTrait.php
+++ b/src/QuerySpanTrait.php
@@ -60,8 +60,9 @@ public function addTransactionSpan(LoggedQuery $query, ?string $connectionName =
}
if ($connectionName) {
- $connection = ConnectionManager::get($connectionName);
- $dialect = $connection->getDriver()->schemaDialect();
+ /** @var \Cake\Database\Driver $driver */
+ $driver = ConnectionManager::get($connectionName)->getDriver();
+ $dialect = $driver->schemaDialect();
$type = match (true) {
$dialect instanceof PostgresSchemaDialect => 'postgresql',
$dialect instanceof SqliteSchemaDialect => 'sqlite',