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
@@ -228,6 +229,55 @@ If the `error` property is set to `true`, an error will be thrown for violations
228
229
</rule>
229
230
```
230
231
232
+
### Generic.Formatting.SpaceAfterNot
233
+
234
+
Property Name | Type | Default | Available Since
235
+
-------------- | ---- | ------- | ---------------
236
+
spacing | int | 1 | 3.4.0
237
+
ignoreNewlines | bool | false | 3.4.0
238
+
239
+
This sniff checks the spacing after a `!` operator. By default, the sniff ensures there is one space after the operator, as shown in the following code snippet:
240
+
241
+
```php
242
+
if (! $foo) {
243
+
}
244
+
```
245
+
246
+
Another common way of using the `!` operator is to follow it with no space, as shown in the following code snippet:
247
+
248
+
```php
249
+
if (!$foo) {
250
+
}
251
+
```
252
+
253
+
If you prefer to write your code like this, you can set the `spacing` property to `0`, or whatever padding you prefer.
254
+
255
+
```xml
256
+
<ruleref="Generic.Formatting.SpaceAfterNot">
257
+
<properties>
258
+
<propertyname="spacing"value="0" />
259
+
</properties>
260
+
</rule>
261
+
```
262
+
263
+
Sometimes complex statements are broken over multiple lines for readability, as shown in the following code snippet:
264
+
```php
265
+
if (!
266
+
($foo || $bar)
267
+
) {
268
+
}
269
+
```
270
+
271
+
By default, this sniff will generate an error if the `!` operator is followed by a newline. Setting the `ignoreNewlines` property to `true` will allow newline characters after a `!` operator.
0 commit comments