combine_nested_dirname.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ===============================
  2. Rule ``combine_nested_dirname``
  3. ===============================
  4. Replace multiple nested calls of ``dirname`` by only one call with second
  5. ``$level`` parameter.
  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. - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
  29. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  30. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  31. References
  32. ----------
  33. - Fixer class: `PhpCsFixer\\Fixer\\FunctionNotation\\CombineNestedDirnameFixer <./../../../src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php>`_
  34. - Test class: `PhpCsFixer\\Tests\\Fixer\\FunctionNotation\\CombineNestedDirnameFixerTest <./../../../tests/Fixer/FunctionNotation/CombineNestedDirnameFixerTest.php>`_
  35. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.