non_printable_character.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Risky when strings contain intended invisible characters.
  11. Configuration
  12. -------------
  13. ``use_escape_sequences_in_strings``
  14. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. Whether characters should be replaced with escape sequences in strings.
  16. Allowed types: ``bool``
  17. Default value: ``true``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. -<?php echo "​Hello World !";
  27. +<?php echo "\u{200b}Hello\u{2007}World\u{a0}!";
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['use_escape_sequences_in_strings' => false]``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. -<?php echo "​Hello World !";
  35. +<?php echo "Hello World !";
  36. Rule sets
  37. ---------
  38. The rule is part of the following rule sets:
  39. - `@PHP70Migration:risky <./../../ruleSets/PHP70MigrationRisky.rst>`_
  40. - `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
  41. - `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
  42. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
  43. - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
  44. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  45. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  46. References
  47. ----------
  48. - Fixer class: `PhpCsFixer\\Fixer\\Basic\\NonPrintableCharacterFixer <./../../../src/Fixer/Basic/NonPrintableCharacterFixer.php>`_
  49. - Test class: `PhpCsFixer\\Tests\\Fixer\\Basic\\NonPrintableCharacterFixerTest <./../../../tests/Fixer/Basic/NonPrintableCharacterFixerTest.php>`_
  50. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.