doc/rules/string_notation/explicit_string_variable.rst
explicit_string_variableConverts implicit variables into explicit ones in double-quoted strings or heredoc syntax.
The reasoning behind this rule is the following:
"$var" syntax as implicit and "{$var}" syntax as
explicit: explicit code should always be preferred."{$var}IsAVar", implicit doesn't.backtick_to_shell_exec fixer to normalize backticks to strings.Example #1
.. code-block:: diff
--- Original
+++ New
<?php
-$a = "My name is $name !";
-$b = "I live in $state->country !";
-$c = "I have $farm[0] chickens !";
+$a = "My name is {$name} !";
+$b = "I live in {$state->country} !";
+$c = "I have {$farm[0]} chickens !";
Rule sets
---------
The rule is part of the following rule set:
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
References
----------
- Fixer class: `PhpCsFixer\\Fixer\\StringNotation\\ExplicitStringVariableFixer <./../../../src/Fixer/StringNotation/ExplicitStringVariableFixer.php>`_
- Test class: `PhpCsFixer\\Tests\\Fixer\\StringNotation\\ExplicitStringVariableFixerTest <./../../../tests/Fixer/StringNotation/ExplicitStringVariableFixerTest.php>`_
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.