cast_spaces.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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'``, ``'single'``
  11. Default value: ``'single'``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. @@ -1,3 +1,3 @@
  21. <?php
  22. -$bar = ( string ) $a;
  23. -$foo = (int)$b;
  24. +$bar = (string) $a;
  25. +$foo = (int) $b;
  26. Example #2
  27. ~~~~~~~~~~
  28. With configuration: ``['space' => 'single']``.
  29. .. code-block:: diff
  30. --- Original
  31. +++ New
  32. @@ -1,3 +1,3 @@
  33. <?php
  34. -$bar = ( string ) $a;
  35. -$foo = (int)$b;
  36. +$bar = (string) $a;
  37. +$foo = (int) $b;
  38. Example #3
  39. ~~~~~~~~~~
  40. With configuration: ``['space' => 'none']``.
  41. .. code-block:: diff
  42. --- Original
  43. +++ New
  44. @@ -1,3 +1,3 @@
  45. <?php
  46. -$bar = ( string ) $a;
  47. -$foo = (int) $b;
  48. +$bar = (string)$a;
  49. +$foo = (int)$b;
  50. Rule sets
  51. ---------
  52. The rule is part of the following rule sets:
  53. @Symfony
  54. Using the ``@Symfony`` rule set will enable the ``cast_spaces`` rule with the default config.
  55. @PhpCsFixer
  56. Using the ``@PhpCsFixer`` rule set will enable the ``cast_spaces`` rule with the default config.