error_suppression.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Risky because adding/removing ``@`` might cause changes to code behaviour or if
  11. ``trigger_error`` function is overridden.
  12. Configuration
  13. -------------
  14. ``mute_deprecation_error``
  15. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. Whether to add ``@`` in deprecation notices.
  17. Allowed types: ``bool``
  18. Default value: ``true``
  19. ``noise_remaining_usages``
  20. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. Whether to remove ``@`` in remaining usages.
  22. Allowed types: ``bool``
  23. Default value: ``false``
  24. ``noise_remaining_usages_exclude``
  25. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. List of global functions to exclude from removing ``@``.
  27. Allowed types: ``list<string>``
  28. Default value: ``[]``
  29. Examples
  30. --------
  31. Example #1
  32. ~~~~~~~~~~
  33. *Default* configuration.
  34. .. code-block:: diff
  35. --- Original
  36. +++ New
  37. <?php
  38. -trigger_error('Warning.', E_USER_DEPRECATED);
  39. +@trigger_error('Warning.', E_USER_DEPRECATED);
  40. Example #2
  41. ~~~~~~~~~~
  42. With configuration: ``['noise_remaining_usages' => true]``.
  43. .. code-block:: diff
  44. --- Original
  45. +++ New
  46. <?php
  47. -@mkdir($dir);
  48. -@unlink($path);
  49. +mkdir($dir);
  50. +unlink($path);
  51. Example #3
  52. ~~~~~~~~~~
  53. With configuration: ``['noise_remaining_usages' => true, 'noise_remaining_usages_exclude' => ['unlink']]``.
  54. .. code-block:: diff
  55. --- Original
  56. +++ New
  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 <./../../ruleSets/PhpCsFixerRisky.rst>`_
  65. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  66. References
  67. ----------
  68. - Fixer class: `PhpCsFixer\\Fixer\\LanguageConstruct\\ErrorSuppressionFixer <./../../../src/Fixer/LanguageConstruct/ErrorSuppressionFixer.php>`_
  69. - Test class: `PhpCsFixer\\Tests\\Fixer\\LanguageConstruct\\ErrorSuppressionFixerTest <./../../../tests/Fixer/LanguageConstruct/ErrorSuppressionFixerTest.php>`_
  70. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.