phpdoc_add_missing_param_annotation.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ============================================
  2. Rule ``phpdoc_add_missing_param_annotation``
  3. ============================================
  4. PHPDoc should contain ``@param`` for all params.
  5. Configuration
  6. -------------
  7. ``only_untyped``
  8. ~~~~~~~~~~~~~~~~
  9. Whether to add missing ``@param`` annotations for untyped parameters only.
  10. Allowed types: ``bool``
  11. Default value: ``true``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. /**
  22. * @param int $bar
  23. + * @param mixed $baz
  24. *
  25. * @return void
  26. */
  27. function f9(string $foo, $bar, $baz) {}
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['only_untyped' => true]``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php
  35. /**
  36. * @param int $bar
  37. + * @param mixed $baz
  38. *
  39. * @return void
  40. */
  41. function f9(string $foo, $bar, $baz) {}
  42. Example #3
  43. ~~~~~~~~~~
  44. With configuration: ``['only_untyped' => false]``.
  45. .. code-block:: diff
  46. --- Original
  47. +++ New
  48. <?php
  49. /**
  50. * @param int $bar
  51. + * @param string $foo
  52. + * @param mixed $baz
  53. *
  54. * @return void
  55. */
  56. function f9(string $foo, $bar, $baz) {}
  57. Rule sets
  58. ---------
  59. The rule is part of the following rule set:
  60. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  61. References
  62. ----------
  63. - Fixer class: `PhpCsFixer\\Fixer\\Phpdoc\\PhpdocAddMissingParamAnnotationFixer <./../../../src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php>`_
  64. - Test class: `PhpCsFixer\\Tests\\Fixer\\Phpdoc\\PhpdocAddMissingParamAnnotationFixerTest <./../../../tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php>`_
  65. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.