3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
/**
8
9
* Stream filter that collect the data that is going through the stream
11
12
*/
12
13
namespace Magento \Test \Profiler ;
13
14
15
+ use PHPUnit \Framework \Assert ;
16
+
14
17
class OutputBambooTestFilter extends \php_user_filter
15
18
{
19
+ /**
20
+ * @var string
21
+ */
16
22
private static $ _collectedData = '' ;
17
23
18
24
/**
19
- * Collect intercepted data
25
+ * Collect intercepted data.
20
26
*
21
27
* @param resource $in
22
28
* @param resource $out
23
29
* @param int $consumed
24
30
* @param bool $closing
25
- * @return int
26
31
*
32
+ * @return int
27
33
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
28
34
* @SuppressWarnings(PHPMD.ShortVariable)
29
35
*/
30
- public function filter ($ in , $ out , &$ consumed , $ closing )
36
+ public function filter ($ in , $ out , &$ consumed , $ closing ): int
31
37
{
32
38
while ($ bucket = stream_bucket_make_writeable ($ in )) {
33
39
self ::$ _collectedData .= $ bucket ->data ;
@@ -37,19 +43,26 @@ public function filter($in, $out, &$consumed, $closing)
37
43
return PSFS_PASS_ON ;
38
44
}
39
45
40
- public static function resetCollectedData ()
46
+ /**
47
+ * This method to reset collection data.
48
+ *
49
+ * @return void
50
+ */
51
+ public static function resetCollectedData (): void
41
52
{
42
53
self ::$ _collectedData = '' ;
43
54
}
44
55
45
56
/**
46
- * Assert that collected data matches expected format
57
+ * Assert that collected data matches expected format.
47
58
*
48
59
* @param string $expectedData
60
+ *
61
+ * @return void
49
62
*/
50
- public static function assertCollectedData ($ expectedData )
63
+ public static function assertCollectedData (string $ expectedData ): void
51
64
{
52
- \ PHPUnit \ Framework \ Assert::assertStringMatchesFormat (
65
+ Assert::assertStringMatchesFormat (
53
66
$ expectedData ,
54
67
self ::$ _collectedData ,
55
68
'Expected data went through the stream. '
0 commit comments