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