phpdoc_scalar.rst 1.4 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 map of types to fix.
  11. Allowed values: a subset of ``['boolean', 'callback', 'double', 'integer', 'real', 'str']``
  12. Default value: ``['boolean', 'double', 'integer', 'real', 'str']``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. @@ -1,12 +1,12 @@
  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. return sample2($a, $b, $c);
  37. }
  38. Example #2
  39. ~~~~~~~~~~
  40. With configuration: ``['types' => ['boolean']]``.
  41. .. code-block:: diff
  42. --- Original
  43. +++ New
  44. @@ -1,5 +1,5 @@
  45. <?php
  46. /**
  47. * @param integer $a
  48. - * @param boolean $b
  49. + * @param bool $b
  50. * @param real $c
  51. Rule sets
  52. ---------
  53. The rule is part of the following rule sets:
  54. @Symfony
  55. Using the ``@Symfony`` rule set will enable the ``phpdoc_scalar`` rule with the default config.
  56. @PhpCsFixer
  57. Using the ``@PhpCsFixer`` rule set will enable the ``phpdoc_scalar`` rule with the default config.