single_quote.rst 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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>`_