You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -229,6 +230,45 @@ If the `error` property is set to `true`, an error will be thrown for violations
229
230
</rule>
230
231
```
231
232
233
+
### Generic.Formatting.SpaceAfterCast
234
+
235
+
Property Name | Type | Default | Available Since
236
+
-------------- | ---- | ------- | ---------------
237
+
spacing | int | 1 | 3.4.0
238
+
ignoreNewlines | bool | false | 3.4.0
239
+
240
+
This sniff checks the spacing after a type cast. By default, the sniff ensures there is one space after the cast, as shown in the following code snippet:
241
+
242
+
```php
243
+
$var = (int) $foo;
244
+
```
245
+
246
+
Another common way of type casting is to follow the cast with no space, as shown in the following code snippet:
247
+
248
+
```php
249
+
$var = (int)$foo;
250
+
```
251
+
252
+
If you prefer to write your code like this, you can set the `spacing` property to `0`, or whatever padding you prefer.
253
+
254
+
```xml
255
+
<ruleref="Generic.Formatting.SpaceAfterCast">
256
+
<properties>
257
+
<propertyname="spacing"value="0" />
258
+
</properties>
259
+
</rule>
260
+
```
261
+
262
+
Sometimes complex statements are broken over multiple lines for readability. By default, this sniff will generate an error if the type cast is followed by a newline. Setting the `ignoreNewlines` property to `true` will allow newline characters after a type cast.
0 commit comments