phpdoc_scalar.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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>`_
  59. References
  60. ----------
  61. - Fixer class: `PhpCsFixer\\Fixer\\Phpdoc\\PhpdocScalarFixer <./../../../src/Fixer/Phpdoc/PhpdocScalarFixer.php>`_
  62. - Test class: `PhpCsFixer\\Tests\\Fixer\\Phpdoc\\PhpdocScalarFixerTest <./../../../tests/Fixer/Phpdoc/PhpdocScalarFixerTest.php>`_
  63. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.