Rule non_printable_character¶
Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.
Warnings¶
This rule is RISKY¶
Risky when strings contain intended invisible characters.
This rule is CONFIGURABLE¶
You can configure this rule using the following option:
use_escape_sequences_in_strings.
Configuration¶
use_escape_sequences_in_strings¶
Whether characters should be replaced with escape sequences in strings.
Allowed types: bool
Default value: true
Examples¶
Example #1¶
Default configuration.
--- Original
+++ New
-<?php echo "Hello World !";
+<?php echo "\u{200b}Hello\u{2007}World\u{a0}!";
Example #2¶
With configuration: ['use_escape_sequences_in_strings' => false].
--- Original
+++ New
-<?php echo "Hello World !";
+<?php echo "Hello World !";
Rule sets¶
The rule is part of the following rule sets:
@PHP70Migration:risky (deprecated)
@PHP71Migration:risky (deprecated)
@PHP74Migration:risky (deprecated)
@PHP80Migration:risky (deprecated)
@PHP82Migration:risky (deprecated)
References¶
Fixer class: PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer
Test class: PhpCsFixer\Tests\Fixer\Basic\NonPrintableCharacterFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.