combine_nested_dirname.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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
  25. Using the `@PHP70Migration:risky <./../../ruleSets/PHP70MigrationRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.
  26. @PHP71Migration:risky
  27. Using the `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.
  28. @PHP74Migration:risky
  29. Using the `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.
  30. @PHP80Migration:risky
  31. Using the `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.
  32. @PhpCsFixer:risky
  33. Using the `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.
  34. @Symfony:risky
  35. Using the `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_ rule set will enable the ``combine_nested_dirname`` rule.