Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 713 Bytes

explicit_indirect_variable.rst

File metadata and controls

34 lines (26 loc) · 713 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:

@PhpCsFixer
Using the @PhpCsFixer rule set will enable the explicit_indirect_variable rule.