Fork me on GitHub
a Sensio Labs Product

BoY42 (v3.15.1) edition

Rule cast_spaces

A single space or none should be between cast and variable.

Configuration

space

spacing to apply between cast and variable.

Allowed values: 'none', 'single'

Default value: 'single'

Examples

Example #1

Default configuration.

--- Original
+++ New
 <?php
-$bar = ( string )  $a;
-$foo = (int)$b;
+$bar = (string) $a;
+$foo = (int) $b;

Example #2

With configuration: ['space' => 'single'].

--- Original
+++ New
 <?php
-$bar = ( string )  $a;
-$foo = (int)$b;
+$bar = (string) $a;
+$foo = (int) $b;

Example #3

With configuration: ['space' => 'none'].

--- Original
+++ New
 <?php
-$bar = ( string )  $a;
-$foo = (int) $b;
+$bar = (string)$a;
+$foo = (int)$b;

Rule sets

The rule is part of the following rule sets:

@PhpCsFixer

Using the @PhpCsFixer rule set will enable the cast_spaces rule with the default config.

@Symfony

Using the @Symfony rule set will enable the cast_spaces rule with the default config.

The logo is © 2010-2022 Sensio Labs