blank_lines_before_namespace.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. =====================================
  2. Rule ``blank_lines_before_namespace``
  3. =====================================
  4. Controls blank lines before a namespace declaration.
  5. Configuration
  6. -------------
  7. ``min_line_breaks``
  8. ~~~~~~~~~~~~~~~~~~~
  9. Minimum line breaks that should exist before namespace declaration.
  10. Allowed types: ``int``
  11. Default value: ``2``
  12. ``max_line_breaks``
  13. ~~~~~~~~~~~~~~~~~~~
  14. Maximum line breaks that should exist before namespace declaration.
  15. Allowed types: ``int``
  16. Default value: ``2``
  17. Examples
  18. --------
  19. Example #1
  20. ~~~~~~~~~~
  21. *Default* configuration.
  22. .. code-block:: diff
  23. --- Original
  24. +++ New
  25. -<?php namespace A {}
  26. +<?php
  27. +
  28. +namespace A {}
  29. Example #2
  30. ~~~~~~~~~~
  31. With configuration: ``['min_line_breaks' => 1]``.
  32. .. code-block:: diff
  33. --- Original
  34. +++ New
  35. -<?php namespace A {}
  36. +<?php
  37. +namespace A {}
  38. Example #3
  39. ~~~~~~~~~~
  40. With configuration: ``['max_line_breaks' => 2]``.
  41. .. code-block:: diff
  42. --- Original
  43. +++ New
  44. <?php
  45. declare(strict_types=1);
  46. -
  47. -
  48. namespace A{}
  49. Example #4
  50. ~~~~~~~~~~
  51. With configuration: ``['min_line_breaks' => 2]``.
  52. .. code-block:: diff
  53. --- Original
  54. +++ New
  55. <?php
  56. /** Some comment */
  57. +
  58. namespace A{}
  59. Example #5
  60. ~~~~~~~~~~
  61. With configuration: ``['min_line_breaks' => 0, 'max_line_breaks' => 0]``.
  62. .. code-block:: diff
  63. --- Original
  64. +++ New
  65. -<?php
  66. -
  67. -namespace A{}
  68. +<?php namespace A{}
  69. Rule sets
  70. ---------
  71. The rule is part of the following rule sets:
  72. - `@PER <./../../ruleSets/PER.rst>`_
  73. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  74. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  75. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  76. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  77. - `@Symfony <./../../ruleSets/Symfony.rst>`_