phpdoc_scalar.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ======================
  2. Rule ``phpdoc_scalar``
  3. ======================
  4. Scalar types should always be written in the same form. ``int`` not ``integer``,
  5. ``bool`` not ``boolean``, ``float`` not ``real`` or ``double``.
  6. Configuration
  7. -------------
  8. ``types``
  9. ~~~~~~~~~
  10. A list of types to fix.
  11. Allowed values: a subset of ``['boolean', 'callback', 'double', 'integer', 'real', 'str']``
  12. Default value: ``['boolean', 'callback', 'double', 'integer', 'real', 'str']``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. /**
  23. - * @param integer $a
  24. - * @param boolean $b
  25. - * @param real $c
  26. + * @param int $a
  27. + * @param bool $b
  28. + * @param float $c
  29. *
  30. - * @return double
  31. + * @return float
  32. */
  33. function sample($a, $b, $c)
  34. {
  35. return sample2($a, $b, $c);
  36. }
  37. Example #2
  38. ~~~~~~~~~~
  39. With configuration: ``['types' => ['boolean']]``.
  40. .. code-block:: diff
  41. --- Original
  42. +++ New
  43. <?php
  44. /**
  45. * @param integer $a
  46. - * @param boolean $b
  47. + * @param bool $b
  48. * @param real $c
  49. */
  50. function sample($a, $b, $c)
  51. {
  52. return sample2($a, $b, $c);
  53. }
  54. Rule sets
  55. ---------
  56. The rule is part of the following rule sets:
  57. @PhpCsFixer
  58. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``phpdoc_scalar`` rule with the default config.
  59. @Symfony
  60. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``phpdoc_scalar`` rule with the default config.