explicit_indirect_variable.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ===================================
  2. Rule ``explicit_indirect_variable``
  3. ===================================
  4. Add curly braces to indirect variables to make them clear to understand.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -echo $$foo;
  14. -echo $$foo['bar'];
  15. -echo $foo->$bar['baz'];
  16. -echo $foo->$callback($baz);
  17. +echo ${$foo};
  18. +echo ${$foo}['bar'];
  19. +echo $foo->{$bar}['baz'];
  20. +echo $foo->{$callback}($baz);
  21. Rule sets
  22. ---------
  23. The rule is part of the following rule set:
  24. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  25. References
  26. ----------
  27. - Fixer class: `PhpCsFixer\\Fixer\\LanguageConstruct\\ExplicitIndirectVariableFixer <./../../../src/Fixer/LanguageConstruct/ExplicitIndirectVariableFixer.php>`_
  28. - Test class: `PhpCsFixer\\Tests\\Fixer\\LanguageConstruct\\ExplicitIndirectVariableFixerTest <./../../../tests/Fixer/LanguageConstruct/ExplicitIndirectVariableFixerTest.php>`_
  29. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.