3
3
4
4
namespace CakeSentry ;
5
5
6
+ use Cake \Event \EventInterface ;
6
7
use Cake \Event \EventListenerInterface ;
8
+ use Cake \View \Cell ;
7
9
8
10
class EventListener implements EventListenerInterface
9
11
{
@@ -16,17 +18,17 @@ class EventListener implements EventListenerInterface
16
18
*/
17
19
public function implementedEvents (): array
18
20
{
19
- $ before = function ($ name ) {
21
+ $ before = function (string $ name ): callable {
20
22
return function () use ($ name ): void {
21
23
DebugTimer::start ($ name );
22
24
};
23
25
};
24
- $ after = function ($ name ) {
26
+ $ after = function (string $ name ): callable {
25
27
return function () use ($ name ): void {
26
28
DebugTimer::stop ($ name );
27
29
};
28
30
};
29
- $ both = function ($ name ) use ($ before , $ after ) {
31
+ $ both = function (string $ name ) use ($ before , $ after ): array {
30
32
return [
31
33
['priority ' => 0 , 'callable ' => $ before ('Event: ' . $ name )],
32
34
['priority ' => 999 , 'callable ' => $ after ('Event: ' . $ name )],
@@ -60,22 +62,22 @@ public function implementedEvents(): array
60
62
'View.beforeLayout ' => $ both ('View.beforeLayout ' ),
61
63
'View.afterLayout ' => $ both ('View.afterLayout ' ),
62
64
'Cell.beforeAction ' => [
63
- ['priority ' => 0 , 'callable ' => function ($ event , $ cell , $ action ): void {
65
+ ['priority ' => 0 , 'callable ' => function (EventInterface $ event , Cell $ cell , string $ action ): void {
64
66
DebugTimer::start ('Cell.Action ' . get_class ($ cell ) . ':: ' . $ action );
65
67
}],
66
68
],
67
69
'Cell.afterAction ' => [
68
- ['priority ' => 0 , 'callable ' => function ($ event , $ cell , $ action ): void {
70
+ ['priority ' => 0 , 'callable ' => function (EventInterface $ event , Cell $ cell , string $ action ): void {
69
71
DebugTimer::stop ('Cell.Action ' . get_class ($ cell ) . ':: ' . $ action );
70
72
}],
71
73
],
72
74
'View.beforeRenderFile ' => [
73
- ['priority ' => 0 , 'callable ' => function ($ event , $ filename ): void {
75
+ ['priority ' => 0 , 'callable ' => function (EventInterface $ event , string $ filename ): void {
74
76
DebugTimer::start ('Render File: ' . $ filename );
75
77
}],
76
78
],
77
79
'View.afterRenderFile ' => [
78
- ['priority ' => 0 , 'callable ' => function ($ event , $ filename ): void {
80
+ ['priority ' => 0 , 'callable ' => function (EventInterface $ event , string $ filename ): void {
79
81
DebugTimer::stop ('Render File: ' . $ filename );
80
82
}],
81
83
],
0 commit comments