single_quote.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. @@ -1,4 +1,4 @@
  21. <?php
  22. -$a = "sample";
  23. +$a = 'sample';
  24. $b = "sample with 'single-quotes'";
  25. Example #2
  26. ~~~~~~~~~~
  27. With configuration: ``['strings_containing_single_quote_chars' => true]``.
  28. .. code-block:: diff
  29. --- Original
  30. +++ New
  31. @@ -1,4 +1,4 @@
  32. <?php
  33. -$a = "sample";
  34. -$b = "sample with 'single-quotes'";
  35. +$a = 'sample';
  36. +$b = 'sample with \'single-quotes\'';
  37. Rule sets
  38. ---------
  39. The rule is part of the following rule sets:
  40. @Symfony
  41. Using the ``@Symfony`` rule set will enable the ``single_quote`` rule with the default config.
  42. @PhpCsFixer
  43. Using the ``@PhpCsFixer`` rule set will enable the ``single_quote`` rule with the default config.