phpdoc_scalar.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <./../../ruleSets/PhpCsFixer.rst>`_
  58. - `@Symfony <./../../ruleSets/Symfony.rst>`_