Skip to content

Commit fa507c4

Browse files
committed
Merge branch '3.x' into 3.next
# Conflicts: # .phive/phars.xml # phpstan.neon # psalm-baseline.xml # src/CakeSentryInit.php
2 parents 1aca98e + 7fbe98a commit fa507c4

File tree

9 files changed

+27
-45
lines changed

9 files changed

+27
-45
lines changed

.phive/phars.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="1.12.3" installed="1.12.3" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
3+
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
4+
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
55
</phive>

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
parameters:
22
paths:
33
- src/
4-
level: 5
4+
level: 8
55
bootstrapFiles:
66
- tests/bootstrap.php
7+
ignoreErrors:
8+
-
9+
identifier: missingType.iterableValue

psalm-baseline.xml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
2+
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
33
<file src="src/Database/Log/CakeSentryLog.php">
4+
<DocblockTypeContradiction>
5+
<code><![CDATA[str_contains($querystring, 'FROM information_schema')]]></code>
6+
</DocblockTypeContradiction>
47
<InternalMethod>
58
<code><![CDATA[getContext]]></code>
69
<code><![CDATA[getContext]]></code>
710
<code><![CDATA[jsonSerialize]]></code>
811
</InternalMethod>
9-
<RiskyTruthyFalsyComparison>
10-
<code><![CDATA[!$querystring]]></code>
11-
</RiskyTruthyFalsyComparison>
12-
</file>
13-
<file src="src/DebugTimer.php">
14-
<RiskyTruthyFalsyComparison>
15-
<code><![CDATA[!$message]]></code>
16-
<code><![CDATA[!$name]]></code>
17-
<code><![CDATA[!$name]]></code>
18-
<code><![CDATA[$name]]></code>
19-
</RiskyTruthyFalsyComparison>
20-
</file>
21-
<file src="src/EventSpanTrait.php">
22-
<RiskyTruthyFalsyComparison>
23-
<code><![CDATA[$endTime]]></code>
24-
<code><![CDATA[$startTime]]></code>
25-
</RiskyTruthyFalsyComparison>
2612
</file>
2713
<file src="src/Http/SentryClient.php">
2814
<InternalMethod>
2915
<code><![CDATA[getContext]]></code>
3016
</InternalMethod>
31-
<RiskyTruthyFalsyComparison>
32-
<code><![CDATA[$extras]]></code>
33-
<code><![CDATA[$extras]]></code>
34-
</RiskyTruthyFalsyComparison>
3517
</file>
3618
<file src="src/Middleware/CakeSentryPerformanceMiddleware.php">
3719
<RiskyTruthyFalsyComparison>
@@ -47,8 +29,5 @@
4729
<InternalMethod>
4830
<code><![CDATA[getContext]]></code>
4931
</InternalMethod>
50-
<RiskyTruthyFalsyComparison>
51-
<code><![CDATA[$connectionName]]></code>
52-
</RiskyTruthyFalsyComparison>
5332
</file>
5433
</files>

src/CakeSentryInit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function init(): void
3939
}
4040

4141
$config = self::getConfig('sentry');
42-
if (is_array($config) && Hash::check($config, 'dsn')) {
42+
if ($config !== null && Hash::check($config, 'dsn')) {
4343
init($config);
4444
$event = new Event('CakeSentry.Client.afterSetup');
4545
EventManager::instance()->dispatch($event);

src/Database/Log/CakeSentryLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ protected function isSchemaQuery(LoggedQuery $query): bool
196196
$context = $query->getContext();
197197
$querystring = $context['query'] ?? false;
198198

199-
if (!$querystring) {
200-
$querystring = $query->jsonSerialize()['query'];
199+
if ($querystring === '') {
200+
$querystring = $query->jsonSerialize()['query'] ?? '';
201201
}
202202

203203
return // Multiple engines

src/DebugTimer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ class DebugTimer
3131
protected static array $_timers = [];
3232

3333
/**
34-
* Start an benchmarking timer.
34+
* Start a benchmarking timer.
3535
*
36-
* @param string $name The name of the timer to start.
37-
* @param string $message A message for your timer
36+
* @param string|null $name The name of the timer to start.
37+
* @param string|null $message A message for your timer
3838
* @return bool Always true
3939
*/
4040
public static function start(?string $name = null, ?string $message = null): bool
4141
{
4242
$start = microtime(true);
4343

44-
if (!$name) {
44+
if ($name === null) {
4545
$named = false;
4646
$calledFrom = debug_backtrace();
4747
$file = $calledFrom[0]['file'] ?? 'unknown file';
@@ -51,7 +51,7 @@ public static function start(?string $name = null, ?string $message = null): boo
5151
$named = true;
5252
}
5353

54-
if (!$message) {
54+
if ($message === null) {
5555
$message = $name;
5656
}
5757

@@ -80,13 +80,13 @@ public static function start(?string $name = null, ?string $message = null): boo
8080
*
8181
* $name should be the same as the $name used in startTimer().
8282
*
83-
* @param string $name The name of the timer to end.
83+
* @param string|null $name The name of the timer to end.
8484
* @return bool true if timer was ended, false if timer was not started.
8585
*/
8686
public static function stop(?string $name = null): bool
8787
{
8888
$end = microtime(true);
89-
if (!$name) {
89+
if ($name === null) {
9090
$names = array_reverse(array_keys(self::$_timers));
9191
foreach ($names as $name) {
9292
if (!empty(self::$_timers[$name]['end'])) {
@@ -110,7 +110,7 @@ public static function stop(?string $name = null): bool
110110
if (!isset(self::$_timers[$name])) {
111111
return false;
112112
}
113-
if ($name) {
113+
if ($name !== null) {
114114
self::$_timers[$name]['end'] = $end;
115115
}
116116

src/EventSpanTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function addEventSpan(string $name, string $sentryOp, ?float $startTime =
3030
$spanContext->setDescription($name);
3131
$spanContext->setOp($sentryOp);
3232
//$spanContext->setData();
33-
if ($startTime && $endTime) {
33+
if ($startTime !== null && $endTime !== null) {
3434
$spanContext->setStartTimestamp(DebugTimer::requestStartTime() + $startTime);
3535
$spanContext->setEndTimestamp(DebugTimer::requestStartTime() + $endTime);
3636
}

src/Http/SentryClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function captureException(
121121
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('exception', 'request'));
122122
$eventManager->dispatch($event);
123123

124-
if ($extras) {
124+
if ($extras !== null) {
125125
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
126126
$scope->setExtras($extras);
127127
});
@@ -152,7 +152,7 @@ public function captureError(
152152
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('error', 'request'));
153153
$eventManager->dispatch($event);
154154

155-
if ($extras) {
155+
if ($extras !== null) {
156156
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
157157
$scope->setExtras($extras);
158158
});
@@ -163,7 +163,7 @@ public function captureError(
163163

164164
$client = $this->hub->getClient();
165165
if ($client) {
166-
/** @var array<int, array{function?: string, line?: int, file?: string, class?: class-string, type?: string, args?: array}> $trace */
166+
/** @var list<array{function?: string, line?: int, file?: string, class?: class-string, type?: string, args?: array}> $trace */
167167
$trace = $this->cleanedTrace($error->getTrace());
168168
/** @psalm-suppress ArgumentTypeCoercion */
169169
$stacktrace = $client->getStacktraceBuilder()
@@ -196,7 +196,7 @@ public function getHub(): HubInterface
196196
* @param array<array<string, null|int|string|array>> $traces
197197
* @return array<array<string, null|int|string|array>>
198198
*/
199-
private function cleanedTrace(array $traces): array
199+
protected function cleanedTrace(array $traces): array
200200
{
201201
foreach ($traces as $key => $trace) {
202202
if (isset($trace['line']) && ($trace['line'] === '??' || $trace['line'] === '')) {

src/QuerySpanTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function addTransactionSpan(LoggedQuery $query, ?string $connectionName =
5050
return;
5151
}
5252

53-
if ($connectionName) {
53+
if ($connectionName !== null) {
5454
/** @var \Cake\Database\Driver $driver */
5555
$driver = ConnectionManager::get($connectionName)->getDriver();
5656
$dialect = $driver->schemaDialect();

0 commit comments

Comments
 (0)