@@ -54,7 +54,7 @@ public function getCapturedBodyLength(): ?int
54
54
/**
55
55
* Mark the stack as active. If a stack was already active, use it as parent for our stack.
56
56
*/
57
- public function activateStack (Stack $ stack )
57
+ public function activateStack (Stack $ stack ): void
58
58
{
59
59
if (null !== $ this ->activeStack ) {
60
60
$ stack ->setParent ($ this ->activeStack );
@@ -66,100 +66,90 @@ public function activateStack(Stack $stack)
66
66
/**
67
67
* Mark the stack as inactive.
68
68
*/
69
- public function deactivateStack (Stack $ stack )
69
+ public function deactivateStack (Stack $ stack ): void
70
70
{
71
71
$ this ->activeStack = $ stack ->getParent ();
72
72
}
73
73
74
- /**
75
- * @return Stack|null
76
- */
77
- public function getActiveStack ()
74
+ public function getActiveStack (): ?Stack
78
75
{
79
76
return $ this ->activeStack ;
80
77
}
81
78
82
- public function addStack (Stack $ stack )
79
+ public function addStack (Stack $ stack ): void
83
80
{
84
81
$ this ->data ['stacks ' ][] = $ stack ;
85
82
}
86
83
87
84
/**
88
85
* @return Stack[]
89
86
*/
90
- public function getChildrenStacks (Stack $ parent )
87
+ public function getChildrenStacks (Stack $ parent ): array
91
88
{
92
- return array_filter ($ this ->data ['stacks ' ], fn (Stack $ stack ) => $ stack ->getParent () === $ parent );
89
+ return array_filter ($ this ->data ['stacks ' ], static fn (Stack $ stack ) => $ stack ->getParent () === $ parent );
93
90
}
94
91
95
92
/**
96
93
* @return Stack[]
97
94
*/
98
- public function getStacks ()
95
+ public function getStacks (): array
99
96
{
100
97
return $ this ->data ['stacks ' ];
101
98
}
102
99
103
100
/**
104
101
* @return Stack[]
105
102
*/
106
- public function getSuccessfulStacks ()
103
+ public function getSuccessfulStacks (): array
107
104
{
108
- return array_filter ($ this ->data ['stacks ' ], fn (Stack $ stack ) => !$ stack ->isFailed ());
105
+ return array_filter ($ this ->data ['stacks ' ], static fn (Stack $ stack ) => !$ stack ->isFailed ());
109
106
}
110
107
111
108
/**
112
109
* @return Stack[]
113
110
*/
114
- public function getFailedStacks ()
111
+ public function getFailedStacks (): array
115
112
{
116
- return array_filter ($ this ->data ['stacks ' ], fn (Stack $ stack ) => $ stack ->isFailed ());
113
+ return array_filter ($ this ->data ['stacks ' ], static fn (Stack $ stack ) => $ stack ->isFailed ());
117
114
}
118
115
119
116
/**
120
- * @return array
117
+ * @return string[]
121
118
*/
122
- public function getClients ()
119
+ public function getClients (): array
123
120
{
124
- $ stacks = array_filter ($ this ->data ['stacks ' ], fn (Stack $ stack ) => null === $ stack ->getParent ());
121
+ $ stacks = array_filter ($ this ->data ['stacks ' ], static fn (Stack $ stack ) => null === $ stack ->getParent ());
125
122
126
- return array_unique (array_map (fn (Stack $ stack ) => $ stack ->getClient (), $ stacks ));
123
+ return array_unique (array_map (static fn (Stack $ stack ) => $ stack ->getClient (), $ stacks ));
127
124
}
128
125
129
126
/**
130
127
* @return Stack[]
131
128
*/
132
- public function getClientRootStacks ($ client )
129
+ public function getClientRootStacks (string $ client ): array
133
130
{
134
- return array_filter ($ this ->data ['stacks ' ], fn (Stack $ stack ) => $ stack ->getClient () == $ client && null == $ stack ->getParent ());
131
+ return array_filter ($ this ->data ['stacks ' ], static fn (Stack $ stack ) => $ stack ->getClient () == $ client && null == $ stack ->getParent ());
135
132
}
136
133
137
134
/**
138
135
* Count all messages for a client.
139
- *
140
- * @return int
141
136
*/
142
- public function countClientMessages ($ client )
137
+ public function countClientMessages (string $ client ): int
143
138
{
144
139
return array_sum (array_map (fn (Stack $ stack ) => $ this ->countStackMessages ($ stack ), $ this ->getClientRootStacks ($ client )));
145
140
}
146
141
147
142
/**
148
143
* Recursively count message in stack.
149
- *
150
- * @return int
151
144
*/
152
- private function countStackMessages (Stack $ stack )
145
+ private function countStackMessages (Stack $ stack ): int
153
146
{
154
147
return 1 + array_sum (array_map (fn (Stack $ child ) => $ this ->countStackMessages ($ child ), $ this ->getChildrenStacks ($ stack )));
155
148
}
156
149
157
- /**
158
- * @return int
159
- */
160
- public function getTotalDuration ()
150
+ public function getTotalDuration (): int
161
151
{
162
- return array_reduce ($ this ->data ['stacks ' ], fn ($ carry , Stack $ stack ) => $ carry + $ stack ->getDuration (), 0 );
152
+ return array_reduce ($ this ->data ['stacks ' ], static fn ($ carry , Stack $ stack ) => $ carry + $ stack ->getDuration (), 0 );
163
153
}
164
154
165
155
public function collect (Request $ request , Response $ response , $ exception = null ): void
0 commit comments