simple_to_complex_string_variable.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ==========================================
  2. Rule ``simple_to_complex_string_variable``
  3. ==========================================
  4. Converts explicit variables in double-quoted strings and heredoc syntax from
  5. simple to complex format (``${`` to ``{$``).
  6. Description
  7. -----------
  8. Doesn't touch implicit variables. Works together nicely with
  9. ``explicit_string_variable``.
  10. Examples
  11. --------
  12. Example #1
  13. ~~~~~~~~~~
  14. .. code-block:: diff
  15. --- Original
  16. +++ New
  17. <?php
  18. $name = 'World';
  19. -echo "Hello ${name}!";
  20. +echo "Hello {$name}!";
  21. Example #2
  22. ~~~~~~~~~~
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. <?php
  27. $name = 'World';
  28. echo <<<TEST
  29. -Hello ${name}!
  30. +Hello {$name}!
  31. TEST;
  32. Rule sets
  33. ---------
  34. The rule is part of the following rule sets:
  35. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
  36. - `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
  37. - `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
  38. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  39. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  40. References
  41. ----------
  42. - Fixer class: `PhpCsFixer\\Fixer\\StringNotation\\SimpleToComplexStringVariableFixer <./../../../src/Fixer/StringNotation/SimpleToComplexStringVariableFixer.php>`_
  43. - Test class: `PhpCsFixer\\Tests\\Fixer\\StringNotation\\SimpleToComplexStringVariableFixerTest <./../../../tests/Fixer/StringNotation/SimpleToComplexStringVariableFixerTest.php>`_
  44. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.