phpdoc_scalar.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. @@ -1,10 +1,10 @@
  22. <?php
  23. /**
  24. - * @param integer $a
  25. - * @param boolean $b
  26. - * @param real $c
  27. + * @param int $a
  28. + * @param bool $b
  29. + * @param float $c
  30. *
  31. - * @return double
  32. + * @return float
  33. */
  34. function sample($a, $b, $c)
  35. {
  36. Example #2
  37. ~~~~~~~~~~
  38. With configuration: ``['types' => ['boolean']]``.
  39. .. code-block:: diff
  40. --- Original
  41. +++ New
  42. @@ -1,7 +1,7 @@
  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. Rule sets
  52. ---------
  53. The rule is part of the following rule sets:
  54. @PhpCsFixer
  55. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``phpdoc_scalar`` rule with the default config.
  56. @Symfony
  57. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``phpdoc_scalar`` rule with the default config.