cast_spaces.rst 1.1 KB

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