cast_spaces.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ====================
  2. Rule ``cast_spaces``
  3. ====================
  4. A single space or none should be between cast and variable.
  5. Configuration
  6. -------------
  7. ``space``
  8. ~~~~~~~~~
  9. Spacing to apply between cast and variable.
  10. Allowed values: ``'none'`` and ``'single'``
  11. Default value: ``'single'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -$bar = ( string ) $a;
  22. -$foo = (int)$b;
  23. +$bar = (string) $a;
  24. +$foo = (int) $b;
  25. Example #2
  26. ~~~~~~~~~~
  27. With configuration: ``['space' => 'single']``.
  28. .. code-block:: diff
  29. --- Original
  30. +++ New
  31. <?php
  32. -$bar = ( string ) $a;
  33. -$foo = (int)$b;
  34. +$bar = (string) $a;
  35. +$foo = (int) $b;
  36. Example #3
  37. ~~~~~~~~~~
  38. With configuration: ``['space' => 'none']``.
  39. .. code-block:: diff
  40. --- Original
  41. +++ New
  42. <?php
  43. -$bar = ( string ) $a;
  44. -$foo = (int) $b;
  45. +$bar = (string)$a;
  46. +$foo = (int)$b;
  47. Rule sets
  48. ---------
  49. The rule is part of the following rule sets:
  50. - `@PER <./../../ruleSets/PER.rst>`_
  51. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  52. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  53. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  54. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  55. References
  56. ----------
  57. - Fixer class: `PhpCsFixer\\Fixer\\CastNotation\\CastSpacesFixer <./../../../src/Fixer/CastNotation/CastSpacesFixer.php>`_
  58. - Test class: `PhpCsFixer\\Tests\\Fixer\\CastNotation\\CastSpacesFixerTest <./../../../tests/Fixer/CastNotation/CastSpacesFixerTest.php>`_
  59. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.