non_printable_character.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ================================
  2. Rule ``non_printable_character``
  3. ================================
  4. Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible
  5. unicode symbols.
  6. .. warning:: Using this rule is risky.
  7. Risky when strings contain intended invisible characters.
  8. Configuration
  9. -------------
  10. ``use_escape_sequences_in_strings``
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. Whether characters should be replaced with escape sequences in strings.
  13. Allowed types: ``bool``
  14. Default value: ``false``
  15. Examples
  16. --------
  17. Example #1
  18. ~~~~~~~~~~
  19. *Default* configuration.
  20. .. code-block:: diff
  21. --- Original
  22. +++ New
  23. @@ -1 +1 @@
  24. -<?php echo "​Hello World !";
  25. +<?php echo "Hello World !";
  26. Example #2
  27. ~~~~~~~~~~
  28. With configuration: ``['use_escape_sequences_in_strings' => true]``.
  29. .. code-block:: diff
  30. --- Original
  31. +++ New
  32. @@ -1 +1 @@
  33. -<?php echo "​Hello World !";
  34. +<?php echo "\u{200b}Hello\u{2007}World\u{a0}!";
  35. Rule sets
  36. ---------
  37. The rule is part of the following rule sets:
  38. @Symfony:risky
  39. Using the ``@Symfony:risky`` rule set will enable the ``non_printable_character`` rule with the default config.
  40. @PhpCsFixer:risky
  41. Using the ``@PhpCsFixer:risky`` rule set will enable the ``non_printable_character`` rule with the default config.
  42. @PHP70Migration:risky
  43. Using the ``@PHP70Migration:risky`` rule set will enable the ``non_printable_character`` rule with the config below:
  44. ``['use_escape_sequences_in_strings' => true]``
  45. @PHP71Migration:risky
  46. Using the ``@PHP71Migration:risky`` rule set will enable the ``non_printable_character`` rule with the config below:
  47. ``['use_escape_sequences_in_strings' => true]``
  48. @PHP80Migration:risky
  49. Using the ``@PHP80Migration:risky`` rule set will enable the ``non_printable_character`` rule with the config below:
  50. ``['use_escape_sequences_in_strings' => true]``