Skip to content

Commit 1221ff3

Browse files
authored
Merge pull request #10 from dereuromark/3.x-fixes
3.x fixes
2 parents 44421eb + de7a32d commit 1221ff3

10 files changed

+41
-18
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.neon]
14+
indent_style = tab

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Set the default behavior for all files.
2+
* text=auto
3+
14
.gitattributes export-ignore
25
.gitignore export-ignore
36
.travis.yml export-ignore

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CakePHP integration for Sentry.
1515
- PHP 8.1+
1616
- CakePHP 5+
1717
- and a [Sentry](https://sentry.io) account
18-
- if you use self hosted sentry make sure you are on at least version `>= v20.6.0`
18+
- if you use self-hosted sentry make sure you are on at least version `>= v20.6.0`
1919

2020
## Version table
2121
| | PHP | CakePHP | self-hosted Sentry |
@@ -82,7 +82,7 @@ You can filter out noisy exceptions which should not be debugged further.
8282
Also see [CakePHP Cookbook](https://book.cakephp.org/4/en/development/errors.html#error-exception-configuration)
8383

8484
### Set Options
85-
Everything inside the `'Sentry'` configuration key will be passed to `\Sentry\init()`.
85+
Everything inside the `'Sentry'` configuration key will be passed to `\Sentry\init()`.
8686
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).
8787

8888
CakeSentry also provides custom event hooks to set dynamic values.
@@ -101,7 +101,7 @@ use Cake\Event\EventListenerInterface;
101101

102102
class SentryOptionsContext implements EventListenerInterface
103103
{
104-
public function implementedEvents(): array
104+
public function implementedEvents(): array
105105
{
106106
return [
107107
'CakeSentry.Client.afterSetup' => 'setServerContext',

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
},
2020
"scripts": {
2121
"test": "phpunit",
22-
"cs-check": "phpcs --colors -p src tests",
23-
"cs-fix": "phpcbf --colors -p src tests",
22+
"cs-check": "phpcs --colors -p src/ tests/",
23+
"cs-fix": "phpcbf --colors -p src/ tests/",
2424
"phpstan": "tools/phpstan analyse",
2525
"psalm": "tools/psalm --show-info=false",
2626
"stan": [

phpstan.neon

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
2-
paths:
3-
- src
4-
- tests/TestCase
5-
level: 5
6-
bootstrapFiles:
7-
- tests/bootstrap.php
2+
paths:
3+
- src/
4+
level: 5
5+
checkMissingIterableValueType: false
6+
bootstrapFiles:
7+
- tests/bootstrap.php

phpunit.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
<testsuites>
1212
<testsuite name="cakephp">
13-
<directory>./tests/TestCase/</directory>
13+
<directory>tests/TestCase/</directory>
1414
</testsuite>
1515
</testsuites>
1616

1717
<!-- Prevent coverage reports from looking in tests, vendors, config folders -->
1818
<source>
1919
<include>
20-
<directory suffix=".php">./src/</directory>
20+
<directory suffix=".php">src/</directory>
2121
</include>
2222
</source>
2323
</phpunit>

src/Http/SentryClient.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ protected function getQueryLoggers(): void
5757
if ($connection->configName() === 'debug_kit') {
5858
continue;
5959
}
60-
$logger = $connection->getDriver()->getLogger();
60+
/** @var \Cake\Database\Driver $driver */
61+
$driver = $connection->getDriver();
62+
$logger = $driver->getLogger();
6163

6264
if ($logger instanceof CakeSentryLog) {
6365
$logger->setIncludeSchema($includeSchemaReflection);
@@ -161,6 +163,7 @@ public function captureError(
161163

162164
$client = $this->hub->getClient();
163165
if ($client) {
166+
/** @var array<int, array{function?: string, line?: int, file?: string, class?: class-string, type?: string, args?: array}> $trace */
164167
$trace = $this->cleanedTrace($error->getTrace());
165168
/** @psalm-suppress ArgumentTypeCoercion */
166169
$stacktrace = $client->getStacktraceBuilder()

src/Middleware/CakeSentryPerformanceMiddleware.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ protected function addQueryData(): void
110110
continue;
111111
}
112112
$logger = null;
113+
/** @var \Cake\Database\Driver $driver */
113114
$driver = $connection->getDriver();
114115
$driverConfig = $driver->config();
115-
if ($driverConfig['sentryLog']) {
116+
if ($driverConfig['sentryLog'] ?? false) {
116117
$logger = $driver->getLogger();
117118
if ($logger instanceof CakeSentryLog) {
118119
$logger->setPerformanceMonitoring(true);

src/Middleware/CakeSentryQueryMiddleware.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ protected function enableQueryLogging(): void
5757
continue;
5858
}
5959
$logger = null;
60+
/** @var \Cake\Database\Driver $driver */
6061
$driver = $connection->getDriver();
6162
$driverConfig = $driver->config();
62-
if ($driverConfig['sentryLog']) {
63+
if ($driverConfig['sentryLog'] ?? false) {
6364
$logger = $driver->getLogger();
6465
}
6566

src/QuerySpanTrait.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ public function addTransactionSpan(LoggedQuery $query, ?string $connectionName =
6060
}
6161

6262
if ($connectionName) {
63-
$connection = ConnectionManager::get($connectionName);
64-
$dialect = $connection->getDriver()->schemaDialect();
63+
/** @var \Cake\Database\Driver $driver */
64+
$driver = ConnectionManager::get($connectionName)->getDriver();
65+
$dialect = $driver->schemaDialect();
6566
$type = match (true) {
6667
$dialect instanceof PostgresSchemaDialect => 'postgresql',
6768
$dialect instanceof SqliteSchemaDialect => 'sqlite',

0 commit comments

Comments
 (0)