normalize_index_brace.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ==============================
  2. Rule ``normalize_index_brace``
  3. ==============================
  4. Array index should always be written by using square braces.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -echo $sample{$index};
  14. +echo $sample[$index];
  15. Rule sets
  16. ---------
  17. The rule is part of the following rule sets:
  18. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  19. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  20. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  21. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
  22. - `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
  23. - `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
  24. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  25. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  26. References
  27. ----------
  28. - Fixer class: `PhpCsFixer\\Fixer\\ArrayNotation\\NormalizeIndexBraceFixer <./../../../src/Fixer/ArrayNotation/NormalizeIndexBraceFixer.php>`_
  29. - Test class: `PhpCsFixer\\Tests\\Fixer\\ArrayNotation\\NormalizeIndexBraceFixerTest <./../../../tests/Fixer/ArrayNotation/NormalizeIndexBraceFixerTest.php>`_
  30. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.