array_push.rst 647 B

1234567891011121314151617181920212223242526272829303132333435
  1. ===================
  2. Rule ``array_push``
  3. ===================
  4. Converts simple usages of ``array_push($x, $y);`` to ``$x[] = $y;``.
  5. .. warning:: Using this rule is risky.
  6. Risky when the function ``array_push`` is overridden.
  7. Examples
  8. --------
  9. Example #1
  10. ~~~~~~~~~~
  11. .. code-block:: diff
  12. --- Original
  13. +++ New
  14. @@ -1,2 +1,2 @@
  15. <?php
  16. -array_push($x, $y);
  17. +$x[] = $y;
  18. Rule sets
  19. ---------
  20. The rule is part of the following rule sets:
  21. @Symfony:risky
  22. Using the ``@Symfony:risky`` rule set will enable the ``array_push`` rule.
  23. @PhpCsFixer:risky
  24. Using the ``@PhpCsFixer:risky`` rule set will enable the ``array_push`` rule.