error_suppression.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ==========================
  2. Rule ``error_suppression``
  3. ==========================
  4. Error control operator should be added to deprecation notices and/or removed
  5. from other cases.
  6. .. warning:: Using this rule is risky.
  7. Risky because adding/removing ``@`` might cause changes to code behaviour or
  8. if ``trigger_error`` function is overridden.
  9. Configuration
  10. -------------
  11. ``mute_deprecation_error``
  12. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. Whether to add ``@`` in deprecation notices.
  14. Allowed types: ``bool``
  15. Default value: ``true``
  16. ``noise_remaining_usages``
  17. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. Whether to remove ``@`` in remaining usages.
  19. Allowed types: ``bool``
  20. Default value: ``false``
  21. ``noise_remaining_usages_exclude``
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. List of global functions to exclude from removing ``@``
  24. Allowed types: ``array``
  25. Default value: ``[]``
  26. Examples
  27. --------
  28. Example #1
  29. ~~~~~~~~~~
  30. *Default* configuration.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. @@ -1,2 +1,2 @@
  35. <?php
  36. -trigger_error('Warning.', E_USER_DEPRECATED);
  37. +@trigger_error('Warning.', E_USER_DEPRECATED);
  38. Example #2
  39. ~~~~~~~~~~
  40. With configuration: ``['noise_remaining_usages' => true]``.
  41. .. code-block:: diff
  42. --- Original
  43. +++ New
  44. @@ -1,3 +1,3 @@
  45. <?php
  46. -@mkdir($dir);
  47. -@unlink($path);
  48. +mkdir($dir);
  49. +unlink($path);
  50. Example #3
  51. ~~~~~~~~~~
  52. With configuration: ``['noise_remaining_usages' => true, 'noise_remaining_usages_exclude' => ['unlink']]``.
  53. .. code-block:: diff
  54. --- Original
  55. +++ New
  56. @@ -1,3 +1,3 @@
  57. <?php
  58. -@mkdir($dir);
  59. +mkdir($dir);
  60. @unlink($path);
  61. Rule sets
  62. ---------
  63. The rule is part of the following rule sets:
  64. @PhpCsFixer:risky
  65. Using the `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ rule set will enable the ``error_suppression`` rule with the default config.
  66. @Symfony:risky
  67. Using the `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_ rule set will enable the ``error_suppression`` rule with the default config.