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
This sniff checks all lines in a file and generates warnings if they are over `lineLimit` characters in length and errors if they are over `absoluteLineLimit` in length. These properties can be used to set the threshold at which errors are reported.
207
207
@@ -298,8 +298,8 @@ If the `error` property is set to `true`, an error will be thrown for violations
298
298
299
299
Property Name | Type | Default | Available Since
300
300
-------------- | ---- | ------- | ---------------
301
-
spacing | int | 1 | 3.4.0
302
301
ignoreNewlines | bool | false | 3.4.0
302
+
spacing | int | 1 | 3.4.0
303
303
304
304
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:
305
305
@@ -337,8 +337,8 @@ Sometimes complex statements are broken over multiple lines for readability. By
337
337
338
338
Property Name | Type | Default | Available Since
339
339
-------------- | ---- | ------- | ---------------
340
-
spacing | int | 1 | 3.4.0
341
340
ignoreNewlines | bool | false | 3.4.0
341
+
spacing | int | 1 | 3.4.0
342
342
343
343
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:
344
344
@@ -386,8 +386,8 @@ By default, this sniff will generate an error if the `!` operator is followed by
386
386
387
387
Property Name | Type | Default | Available Since
388
388
-------------- | ---- | ------- | ---------------
389
-
checkFunctions | bool | true | 2.3.0
390
389
checkClosures | bool | false | 2.3.0
390
+
checkFunctions | bool | true | 2.3.0
391
391
392
392
The sniff checks the position of the opening brace of a function and/or closure (anonymous function). The sniff only checks functions by default, but the `checkFunctions` and `checkClosures` properties can be used to have the sniff check one or both of these code blocks.
393
393
@@ -405,8 +405,8 @@ The sniff checks the position of the opening brace of a function and/or closure
405
405
406
406
Property Name | Type | Default | Available Since
407
407
-------------- | ---- | ------- | ---------------
408
-
checkFunctions | bool | true | 2.3.0
409
408
checkClosures | bool | false | 2.3.0
409
+
checkFunctions | bool | true | 2.3.0
410
410
411
411
The sniff checks the position of the opening brace of a function and/or closure (anonymous function). The sniff only checks functions by default, but the `checkFunctions` and `checkClosures` properties can be used to have the sniff check one or both of these code blocks.
412
412
@@ -424,8 +424,8 @@ The sniff checks the position of the opening brace of a function and/or closure
This sniff discourages the use of alias functions that are kept in PHP for compatibility with older versions. The sniff can be used to forbid the use of any function by setting the `forbiddenFunctions` property. The property is defined as an array, with the keys being the names of the functions to forbid and the values being the names of suggested alternative functions to use instead. If no alternative function exists (i.e., the function should never be used) specify `null` as the value.
495
495
@@ -561,8 +561,8 @@ If the `error` property is set to `false`, a warning will be thrown for violatio
561
561
562
562
Property Name | Type | Default | Available Since
563
563
-------------- | ---- | ------- | ---------------
564
-
spacing | int | 0 | 3.3.0
565
564
ignoreNewlines | bool | false | 3.3.0
565
+
spacing | int | 0 | 3.3.0
566
566
567
567
This sniff checks the padding inside parenthesis that are not being used by function declarations, function calls, or control structures. By default, the sniff ensures there are zero spaces inside the parenthesis, as shown in the following code snippet:
568
568
@@ -600,10 +600,10 @@ Sometimes long statements are broken over multiple lines to work within a maximu
This sniff checks that code blocks are indented correctly. By default, this sniff ensures that code blocks are indented 4 spaces, but you can change the size of the indent by setting the `indent` property.
609
609
@@ -660,8 +660,8 @@ Setting the `ignoreIndentationTokens` property provides the sniff with a list of
660
660
661
661
Property Name | Type | Default | Available Since
662
662
-------------- | ---- | ------- | ---------------
663
-
spacing | int | 0 | 3.5.0
664
663
ignoreNewlines | bool | false | 3.5.0
664
+
spacing | int | 0 | 3.5.0
665
665
666
666
This sniff checks the spacing after a `...` operator. By default, the sniff ensures there is no space after the operator, but you can enforce a fixed number of spaces by setting the `spacing` property.
667
667
@@ -690,9 +690,10 @@ If you want to allow a newline after the operator, you can set the `ignoreNewlin
This sniff verifies that functions are documented using a docblock. By default, all functions are checked regardless of their visibility, but the sniff can be told to ignore private and protected functions using the `minimumVisibility` property. When set to `protected`, only public and protected functions will be checked. When set to `public`, only public functions will be checked.
698
699
@@ -704,7 +705,19 @@ This sniff verifies that functions are documented using a docblock. By default,
704
705
</rule>
705
706
```
706
707
707
-
## PEAR Sniffs
708
+
This sniff also enforces that function docblocks contain a `@return` tag, except for special methods. By default, the `__construct` and `__destruct` methods do not need to specify a return type, but the sniff can be told to not require a return type for other methods by setting the `specialMethods` sniff property.
709
+
710
+
```xml
711
+
<ruleref="PEAR.Commenting.FunctionComment">
712
+
<properties>
713
+
<propertyname="specialMethods"type="array">
714
+
<elementvalue="__construct"/>
715
+
<elementvalue="__destruct"/>
716
+
<elementvalue="ignoreThisFunction"/>
717
+
</property>
718
+
</properties>
719
+
</rule>
720
+
```
708
721
709
722
### PEAR.ControlStructures.ControlSignature
710
723
@@ -760,8 +773,8 @@ One of the rules that this sniff enforces is the indent of an assignment that ha
> Note: The `minimumVisibility`property is inherited from the [PEAR.Commenting.FunctionComment](#pearcommentingfunctioncomment) sniff.
1144
+
> Note: The `minimumVisibility`and `specialMethods` properties are inherited from the [PEAR.Commenting.FunctionComment](#pearcommentingfunctioncomment) sniff.
1131
1145
1132
1146
This sniff verifies that functions are documented using a docblock. By default, all functions are checked regardless of their visibility, but the sniff can be told to ignore private and protected functions using the `minimumVisibility` property. When set to `protected`, only public and protected functions will be checked. When set to `public`, only public functions will be checked.
1133
1147
@@ -1139,6 +1153,20 @@ This sniff verifies that functions are documented using a docblock. By default,
1139
1153
</rule>
1140
1154
```
1141
1155
1156
+
This sniff also enforces that function docblocks contain a `@return` tag, except for special methods. By default, the `__construct` and `__destruct` methods do not need to specify a return type, but the sniff can be told to not require a return type for other methods by setting the `specialMethods` sniff property.
1157
+
1158
+
```xml
1159
+
<ruleref="Squiz.Commenting.FunctionComment">
1160
+
<properties>
1161
+
<propertyname="specialMethods"type="array">
1162
+
<elementvalue="__construct"/>
1163
+
<elementvalue="__destruct"/>
1164
+
<elementvalue="ignoreThisFunction"/>
1165
+
</property>
1166
+
</properties>
1167
+
</rule>
1168
+
```
1169
+
1142
1170
If you make use of the `@inheritdoc` tag to inherit the parent function's entire docblock, the sniff will continue to report errors about missing tags unless you set the `skipIfInheritdoc` property to `true`.
1143
1171
1144
1172
```xml
@@ -1162,8 +1190,8 @@ public function foo($a, $b) {}
This sniff checks that long blocks of code have a closing comment. The `lineLimit` property allows you to configure the numbers of lines that the code block must span before requiring a comment. By default, the code block must be at least 20 lines long, including the opening and closing lines, but you can change the required length by setting the `lineLimit` property.
1169
1197
@@ -1260,9 +1288,9 @@ If you prefer to write your code like this, you can set the `requiredSpacesAfter
This sniff checks that `for` structures have the correct padding inside their bracketed statement. By default, the sniff ensures there are zero spaces following the opening bracket, and zero spaces preceding the closing bracket, as shown in the following code snippet:
1268
1296
@@ -1485,8 +1513,8 @@ If the `error` property is set to `true`, an error will be thrown for violations
1485
1513
1486
1514
Property Name | Type | Default | Available Since
1487
1515
-------------- | ---- | ------- | ---------------
1488
-
spacing | int | 0 | 2.0.0
1489
1516
ignoreNewlines | bool | false | 2.3.1
1517
+
spacing | int | 0 | 2.0.0
1490
1518
1491
1519
One of the rules this sniff enforces is the padding around concatenation operators. By default, the sniff ensures there are zero spaces before and after the concatenation operator, as shown in the following code snippet:
1492
1520
@@ -1525,8 +1553,8 @@ Sometimes long concatenation statements are broken over multiple lines to work w
This sniff checks that there are two blank lines before and after functions declarations, but you can change the required padding using the `spacing`, `spacingBeforeFirst`, and `spacingAfterLast` properties.
0 commit comments