Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 803 Bytes

explicit_indirect_variable.rst

File metadata and controls

38 lines (28 loc) · 803 Bytes

Rule explicit_indirect_variable

Add curly braces to indirect variables to make them clear to understand. Requires PHP >= 7.0.

Examples

Example #1

--- Original
+++ New
 <?php
-echo $$foo;
-echo $$foo['bar'];
-echo $foo->$bar['baz'];
-echo $foo->$callback($baz);
+echo ${$foo};
+echo ${$foo}['bar'];
+echo $foo->{$bar}['baz'];
+echo $foo->{$callback}($baz);

Rule sets

The rule is part of the following rule set:

Source class

PhpCsFixer\Fixer\LanguageConstruct\ExplicitIndirectVariableFixer