Skip to content

Commit 92a2ebb

Browse files
committed
fix stan
1 parent 2a41f20 commit 92a2ebb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/DebugTimer.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ public static function stop(?string $name = null): bool
110110
if (!isset(self::$_timers[$name])) {
111111
return false;
112112
}
113-
self::$_timers[$name]['end'] = $end;
113+
if ($name) {
114+
self::$_timers[$name]['end'] = $end;
115+
}
114116

115117
return true;
116118
}

src/EventListener.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace CakeSentry;
55

6+
use Cake\Event\EventInterface;
67
use Cake\Event\EventListenerInterface;
8+
use Cake\View\Cell;
79

810
class EventListener implements EventListenerInterface
911
{
@@ -16,17 +18,17 @@ class EventListener implements EventListenerInterface
1618
*/
1719
public function implementedEvents(): array
1820
{
19-
$before = function ($name) {
21+
$before = function (string $name): callable {
2022
return function () use ($name): void {
2123
DebugTimer::start($name);
2224
};
2325
};
24-
$after = function ($name) {
26+
$after = function (string $name): callable {
2527
return function () use ($name): void {
2628
DebugTimer::stop($name);
2729
};
2830
};
29-
$both = function ($name) use ($before, $after) {
31+
$both = function (string $name) use ($before, $after): array {
3032
return [
3133
['priority' => 0, 'callable' => $before('Event: ' . $name)],
3234
['priority' => 999, 'callable' => $after('Event: ' . $name)],
@@ -60,22 +62,22 @@ public function implementedEvents(): array
6062
'View.beforeLayout' => $both('View.beforeLayout'),
6163
'View.afterLayout' => $both('View.afterLayout'),
6264
'Cell.beforeAction' => [
63-
['priority' => 0, 'callable' => function ($event, $cell, $action): void {
65+
['priority' => 0, 'callable' => function (EventInterface $event, Cell $cell, string $action): void {
6466
DebugTimer::start('Cell.Action ' . get_class($cell) . '::' . $action);
6567
}],
6668
],
6769
'Cell.afterAction' => [
68-
['priority' => 0, 'callable' => function ($event, $cell, $action): void {
70+
['priority' => 0, 'callable' => function (EventInterface $event, Cell $cell, string $action): void {
6971
DebugTimer::stop('Cell.Action ' . get_class($cell) . '::' . $action);
7072
}],
7173
],
7274
'View.beforeRenderFile' => [
73-
['priority' => 0, 'callable' => function ($event, $filename): void {
75+
['priority' => 0, 'callable' => function (EventInterface $event, string $filename): void {
7476
DebugTimer::start('Render File: ' . $filename);
7577
}],
7678
],
7779
'View.afterRenderFile' => [
78-
['priority' => 0, 'callable' => function ($event, $filename): void {
80+
['priority' => 0, 'callable' => function (EventInterface $event, string $filename): void {
7981
DebugTimer::stop('Render File: ' . $filename);
8082
}],
8183
],

src/EventSpanTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function addEventSpan(string $name, string $sentryOp, ?float $startTime =
2222
return;
2323
}
2424

25-
if ($startTime === 0) {
25+
if ($startTime == 0) {
2626
$startTime = 1;
2727
}
2828

0 commit comments

Comments
 (0)