combine_nested_dirname.rst 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ===============================
  2. Rule ``combine_nested_dirname``
  3. ===============================
  4. Replace multiple nested calls of ``dirname`` by only one call with second
  5. ``$level`` parameter. Requires PHP >= 7.0.
  6. Warning
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Risky when the function ``dirname`` is overridden.
  11. Examples
  12. --------
  13. Example #1
  14. ~~~~~~~~~~
  15. .. code-block:: diff
  16. --- Original
  17. +++ New
  18. <?php
  19. -dirname(dirname(dirname($path)));
  20. +dirname($path, 3);
  21. Rule sets
  22. ---------
  23. The rule is part of the following rule sets:
  24. - `@PHP70Migration:risky <./../../ruleSets/PHP70MigrationRisky.rst>`_
  25. - `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
  26. - `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
  27. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
  28. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  29. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_