single_quote.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. =====================
  2. Rule ``single_quote``
  3. =====================
  4. Convert double quotes to single quotes for simple strings.
  5. Configuration
  6. -------------
  7. ``strings_containing_single_quote_chars``
  8. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. Whether to fix double-quoted strings that contains single-quotes.
  10. Allowed types: ``bool``
  11. Default value: ``false``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -$a = "sample";
  22. +$a = 'sample';
  23. $b = "sample with 'single-quotes'";
  24. Example #2
  25. ~~~~~~~~~~
  26. With configuration: ``['strings_containing_single_quote_chars' => true]``.
  27. .. code-block:: diff
  28. --- Original
  29. +++ New
  30. <?php
  31. -$a = "sample";
  32. -$b = "sample with 'single-quotes'";
  33. +$a = 'sample';
  34. +$b = 'sample with \'single-quotes\'';
  35. Rule sets
  36. ---------
  37. The rule is part of the following rule sets:
  38. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  39. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  40. References
  41. ----------
  42. - Fixer class: `PhpCsFixer\\Fixer\\StringNotation\\SingleQuoteFixer <./../../../src/Fixer/StringNotation/SingleQuoteFixer.php>`_
  43. - Test class: `PhpCsFixer\\Tests\\Fixer\\StringNotation\\SingleQuoteFixerTest <./../../../tests/Fixer/StringNotation/SingleQuoteFixerTest.php>`_
  44. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.