File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Kenjis \PhpUnitHelper ;
6
+
7
+ require_once __DIR__ . '/functions.php ' ;
8
+
9
+ trait DebugHelper
10
+ {
11
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Helper Functions
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+
9
+ /**
10
+ * @SuppressWarnings(PHPMD.ExitExpression)
11
+ * Does not work if I move to the function annotation
12
+ * See https://github.com/phpmd/phpmd/issues/337
13
+ */
14
+ if (! function_exists ('dd ' )) {
15
+ /**
16
+ * Alias of var_dump() and exit()
17
+ *
18
+ * @param mixed ...$vars
19
+ *
20
+ * @psalm-suppress ForbiddenCode Unsafe var_dump
21
+ * @codeCoverageIgnore
22
+ */
23
+ function dd (...$ vars ): void
24
+ {
25
+ var_dump (...$ vars );
26
+ exit ;
27
+ }
28
+ }
29
+
30
+ if (! function_exists ('d ' )) {
31
+ /**
32
+ * Alias of var_dump()
33
+ *
34
+ * @param mixed ...$vars
35
+ *
36
+ * @psalm-suppress ForbiddenCode Unsafe var_dump
37
+ */
38
+ function d (...$ vars ): void
39
+ {
40
+ var_dump (...$ vars );
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Kenjis \PhpUnitHelper ;
6
+
7
+ use PHPUnit \Framework \TestCase ;
8
+
9
+ class DebugHelperTest extends TestCase
10
+ {
11
+ use DebugHelper;
12
+
13
+ public function test_d (): void
14
+ {
15
+ $ this ->expectOutputRegex (
16
+ '/string\(4\) "var1"\n.*\nint\(100\)\n/ '
17
+ );
18
+
19
+ $ var1 = 'var1 ' ;
20
+ $ var2 = 100 ;
21
+ d ($ var1 , $ var2 );
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments