Skip to content

Commit b9a67ed

Browse files
committed
Improved error message
1 parent 629363f commit b9a67ed

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Rule/Debug/DisallowDebugFunctionsRule.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ public function processNode(Node $node, Scope $scope): array
6161

6262
return [
6363
RuleErrorBuilder::message(sprintf(
64-
'Use of debug function "%s" is not allowed',
64+
'Use of debug function "%s" is not allowed. %s',
6565
$usedName,
66+
'The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
6667
))
67-
->identifier('cake.entity.arrayAccess')
68+
->identifier('cake.debug.debugFunctionUse')
6869
->build(),
6970
];
7071
}

tests/TestCase/Rule/Debug/DisallowDebugFunctionsRuleTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,47 @@ public function testRule(): void
2828
// each error consists of the asserted error message, and the asserted error file line
2929
$this->analyse([__DIR__ . '/Fake/FailingDebugUseLogic.php'], [
3030
[
31-
'Use of debug function "debug" is not allowed',
31+
'Use of debug function "debug" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
3232
14, // asserted error line
3333
],
3434
[
35-
'Use of debug function "debug_print_backtrace" is not allowed',
35+
'Use of debug function "debug_print_backtrace" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
3636
15, // asserted error line
3737
],
3838
[
39-
'Use of debug function "debug_zval_dump" is not allowed',
39+
'Use of debug function "debug_zval_dump" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
4040
16, // asserted error line
4141
],
4242
[
43-
'Use of debug function "print_r" is not allowed',
43+
'Use of debug function "print_r" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
4444
19, // asserted error line
4545
],
4646
[
47-
'Use of debug function "print_r" is not allowed',
47+
'Use of debug function "print_r" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
4848
20, // asserted error line
4949
],
5050
[
51-
'Use of debug function "var_dump" is not allowed',
51+
'Use of debug function "var_dump" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
5252
21, // asserted error line
5353
],
5454
[
55-
'Use of debug function "var_export" is not allowed',
55+
'Use of debug function "var_export" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
5656
23, // asserted error line
5757
],
5858
[
59-
'Use of debug function "var_export" is not allowed',
59+
'Use of debug function "var_export" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
6060
24, // asserted error line
6161
],
6262
[
63-
'Use of debug function "stackTrace" is not allowed',
63+
'Use of debug function "stackTrace" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
6464
25, // asserted error line
6565
],
6666
[
67-
'Use of debug function "pr" is not allowed',
67+
'Use of debug function "pr" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
6868
26, // asserted error line
6969
],
7070
[
71-
'Use of debug function "dd" is not allowed',
71+
'Use of debug function "dd" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
7272
28, // asserted error line
7373
],
7474
]);

0 commit comments

Comments
 (0)