doctrine_annotation_spaces.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ===================================
  2. Rule ``doctrine_annotation_spaces``
  3. ===================================
  4. Fixes spaces in Doctrine annotations.
  5. Description
  6. -----------
  7. There must not be any space around parentheses; commas must be preceded by no
  8. space and followed by one space; there must be no space around named arguments
  9. assignment operator; there must be one space around array assignment operator.
  10. Configuration
  11. -------------
  12. ``ignored_tags``
  13. ~~~~~~~~~~~~~~~~
  14. List of tags that must not be treated as Doctrine Annotations.
  15. Allowed types: ``array``
  16. Default value: ``['abstract', 'access', 'code', 'deprec', 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc', 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar', 'staticVar', 'throw', 'api', 'author', 'category', 'copyright', 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal', 'license', 'link', 'method', 'package', 'param', 'property', 'property-read', 'property-write', 'return', 'see', 'since', 'source', 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var', 'version', 'after', 'afterClass', 'backupGlobals', 'backupStaticAttributes', 'before', 'beforeClass', 'codeCoverageIgnore', 'codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass', 'coversNothing', 'dataProvider', 'depends', 'expectedException', 'expectedExceptionCode', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp', 'group', 'large', 'medium', 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses', 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses', 'SuppressWarnings', 'noinspection', 'package_version', 'enduml', 'startuml', 'psalm', 'phpstan', 'template', 'fix', 'FIXME', 'fixme', 'override']``
  17. ``around_parentheses``
  18. ~~~~~~~~~~~~~~~~~~~~~~
  19. Whether to fix spaces around parentheses.
  20. Allowed types: ``bool``
  21. Default value: ``true``
  22. ``around_commas``
  23. ~~~~~~~~~~~~~~~~~
  24. Whether to fix spaces around commas.
  25. Allowed types: ``bool``
  26. Default value: ``true``
  27. ``before_argument_assignments``
  28. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. Whether to add, remove or ignore spaces before argument assignment operator.
  30. Allowed types: ``null`` and ``bool``
  31. Default value: ``false``
  32. ``after_argument_assignments``
  33. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. Whether to add, remove or ignore spaces after argument assignment operator.
  35. Allowed types: ``null`` and ``bool``
  36. Default value: ``false``
  37. ``before_array_assignments_equals``
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. Whether to add, remove or ignore spaces before array ``=`` assignment operator.
  40. Allowed types: ``null`` and ``bool``
  41. Default value: ``true``
  42. ``after_array_assignments_equals``
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. Whether to add, remove or ignore spaces after array assignment ``=`` operator.
  45. Allowed types: ``null`` and ``bool``
  46. Default value: ``true``
  47. ``before_array_assignments_colon``
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. Whether to add, remove or ignore spaces before array ``:`` assignment operator.
  50. Allowed types: ``null`` and ``bool``
  51. Default value: ``true``
  52. ``after_array_assignments_colon``
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. Whether to add, remove or ignore spaces after array assignment ``:`` operator.
  55. Allowed types: ``null`` and ``bool``
  56. Default value: ``true``
  57. Examples
  58. --------
  59. Example #1
  60. ~~~~~~~~~~
  61. *Default* configuration.
  62. .. code-block:: diff
  63. --- Original
  64. +++ New
  65. <?php
  66. /**
  67. - * @Foo ( )
  68. + * @Foo()
  69. */
  70. class Bar {}
  71. /**
  72. - * @Foo("bar" ,"baz")
  73. + * @Foo("bar", "baz")
  74. */
  75. class Bar2 {}
  76. /**
  77. - * @Foo(foo = "foo", bar = {"foo":"foo", "bar"="bar"})
  78. + * @Foo(foo="foo", bar={"foo" : "foo", "bar" = "bar"})
  79. */
  80. class Bar3 {}
  81. Example #2
  82. ~~~~~~~~~~
  83. With configuration: ``['after_array_assignments_equals' => false, 'before_array_assignments_equals' => false]``.
  84. .. code-block:: diff
  85. --- Original
  86. +++ New
  87. <?php
  88. /**
  89. - * @Foo(foo = "foo", bar = {"foo":"foo", "bar"="bar"})
  90. + * @Foo(foo="foo", bar={"foo" : "foo", "bar"="bar"})
  91. */
  92. class Bar {}
  93. Rule sets
  94. ---------
  95. The rule is part of the following rule set:
  96. - `@DoctrineAnnotation <./../../ruleSets/DoctrineAnnotation.rst>`_ with config:
  97. ``['before_array_assignments_colon' => false]``