Skip to content

Commit 7fbe98a

Browse files
authored
Merge pull request #25 from LordSimal/3.x-update-stan
update stan
2 parents 54eacef + 06ed94a commit 7fbe98a

9 files changed

+43
-28
lines changed

.phive/phars.xml

+3-3
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.10.28" installed="1.10.28" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.14.1" installed="5.14.1" location="./tools/psalm" copy="false"/>
5-
</phive>
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"/>
5+
</phive>

phpstan.neon

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
parameters:
22
paths:
33
- src/
4-
level: 5
5-
checkMissingIterableValueType: false
4+
level: 8
65
bootstrapFiles:
76
- tests/bootstrap.php
7+
ignoreErrors:
8+
-
9+
identifier: missingType.iterableValue

psalm-baseline.xml

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.14.1@b9d355e0829c397b9b3b47d0c0ed042a8a70284d">
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>
5-
<code>getContext</code>
6-
<code>getContext</code>
7-
<code>jsonSerialize</code>
8+
<code><![CDATA[getContext]]></code>
9+
<code><![CDATA[getContext]]></code>
10+
<code><![CDATA[jsonSerialize]]></code>
811
</InternalMethod>
912
</file>
1013
<file src="src/Http/SentryClient.php">
1114
<InternalMethod>
12-
<code>getContext</code>
15+
<code><![CDATA[getContext]]></code>
1316
</InternalMethod>
1417
</file>
18+
<file src="src/Middleware/CakeSentryPerformanceMiddleware.php">
19+
<RiskyTruthyFalsyComparison>
20+
<code><![CDATA[$driverConfig['sentryLog'] ?? false]]></code>
21+
</RiskyTruthyFalsyComparison>
22+
</file>
23+
<file src="src/Middleware/CakeSentryQueryMiddleware.php">
24+
<RiskyTruthyFalsyComparison>
25+
<code><![CDATA[$driverConfig['sentryLog'] ?? false]]></code>
26+
</RiskyTruthyFalsyComparison>
27+
</file>
1528
<file src="src/QuerySpanTrait.php">
1629
<InternalMethod>
17-
<code>getContext</code>
30+
<code><![CDATA[getContext]]></code>
1831
</InternalMethod>
1932
</file>
2033
</files>

src/CakeSentryInit.php

+1-1
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 ($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

+2-2
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'] ?? '';
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

+8-8
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

+1-1
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

+4-4
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function addTransactionSpan(LoggedQuery $query, ?string $connectionName =
5959
return;
6060
}
6161

62-
if ($connectionName) {
62+
if ($connectionName !== null) {
6363
/** @var \Cake\Database\Driver $driver */
6464
$driver = ConnectionManager::get($connectionName)->getDriver();
6565
$dialect = $driver->schemaDialect();

0 commit comments

Comments
 (0)