Skip to content

Commit 7c8bdcd

Browse files
committed
docs: change formatting and wording of the sniffs documentation.
1 parent df5b9d9 commit 7c8bdcd

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

yCodeTech/Docs/Commenting/DocblockFormatStandard.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<![CDATA[
44
Enforces proper spacing and formatting in docblocks:
55
1. All docblock tags must have exactly `1 space` between each element.
6-
2. Type and variable in any tags must have exactly `1 space` between them.
6+
2. The type and variable in any tag must be separated by a `space`.
77
3. `@return` tags must be preceded by exactly `1 empty line`.
88
99
]]>

yCodeTech/Docs/Commenting/FunctionCommentStandard.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<documentation title="Function Comment">
22
<standard>
33
<![CDATA[
4-
Non-void returning functions must have a @return docblock tag.
4+
Functions that return a value must have a `@return` docblock tag.
55
66
This rule enforces:
77
8-
1. Functions with non-void return types (string, bool, etc.) must have a `@return` tag.
9-
2. Functions with void return types must NOT have `@return` tags, except generator functions.
10-
3. Generator functions must have a `@return` tag with type iterable.
8+
1. Functions with `non-void` return types (`string`, `bool`, etc.) must have a `@return` tag.
9+
2. Functions with `void` return types must NOT have `@return` tags, except generator functions.
10+
3. Generator functions must have a `@return` tag.
1111
1212
Notes:
1313
1414
- Both typed and untyped functions are checked.
1515
- Return types can be declared or inferred from function signature.
16-
- Magic methods (e.g. __construct, __get, etc.) are exempt from requiring @return tags.
16+
- Magic methods (e.g. `__construct`, `__get`, etc.) are exempt from requiring `@return` tags.
1717
- Fixing `@return` tags will have the type `mixed`, and generator functions will have the type `iterable`; these should then be edited manually to specific types.
1818
1919
---
@@ -32,7 +32,6 @@
3232
*/
3333
public function formatString(string $input): string
3434
{
35-
return strtoupper($input);
3635
}
3736
]]>
3837
</code>
@@ -45,7 +44,6 @@ public function formatString(string $input): string
4544
</em> */
4645
public function formatString(string $input): string
4746
{
48-
return strtoupper($input);
4947
}
5048
]]>
5149
</code>
@@ -61,7 +59,6 @@ public function formatString(string $input): string
6159
</em> */
6260
public function processData(array $data): void
6361
{
64-
// Process data
6562
}
6663
]]>
6764
</code>
@@ -76,7 +73,6 @@ public function processData(array $data): void
7673
*/
7774
public function processData(array $data): void
7875
{
79-
// Process data
8076
}
8177
]]>
8278
</code>

yCodeTech/Docs/Types/DisallowTypeLongNamesStandard.xml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Applies to:
1212
1313
1. Regular docblock tags that contain types (`@param`, `@return`, `@var`, `@property`, `@method`) and any others that contain these regular tags (`@property-read`, `@property-write`, `@phpstan-*`, `@psalm-*`, etc.)
14-
2. Docblock generic types: `array<integer, boolean>``array<int, bool>`, `array<boolean>``array<bool>`, `Collection<integer>``Collection<int>`, etc.
14+
2. Docblock generic types: array<`integer`, `boolean`> → array<`int`, `bool`>, array<`boolean`> → array<`bool`>, Collection<`integer`> → Collection<`int`>, etc.
1515
3. Function/method/closure parameter and return type declarations
1616
4. Class property type declarations
1717
5. Nullable and union types: `?boolean` → `?bool`, `?integer` → `?int`, `boolean|string` → `bool|string`, `integer|string` → `int|string`
@@ -24,6 +24,7 @@
2424
/**
2525
* @param <em>bool</em> $isValid
2626
* @psalm-param <em>bool</em> $isValid
27+
*
2728
* @return <em>int</em>
2829
*/
2930
]]>
@@ -33,6 +34,7 @@
3334
/**
3435
* @param <em>boolean</em> $isValid
3536
* @psalm-param <em>boolean</em> $isValid
37+
*
3638
* @return <em>integer</em>
3739
*/
3840
]]>
@@ -45,7 +47,7 @@
4547
* @param Collection<<em>int</em>> $numbers
4648
* @param Map<string, <em>bool</em>> $settings
4749
* @param array<string, <em>int</em>> $counts
48-
* @param array< <em>bool</em>, <em>int</em>> $counts
50+
* @param array<<em>bool</em>, <em>int</em>> $counts
4951
*/
5052
]]>
5153
</code>
@@ -55,7 +57,7 @@
5557
* @param Collection<<em>integer</em>> $numbers
5658
* @param Map<string, <em>boolean</em>> $settings
5759
* @param array<string, <em>integer</em>> $counts
58-
* @param array< <em>boolean</em>, <em>integer</em>> $counts
60+
* @param array<<em>boolean</em>, <em>integer</em>> $counts
5961
*/
6062
]]>
6163
</code>
@@ -80,21 +82,15 @@ protected <em>integer</em> $userCount;
8082
<![CDATA[
8183
function foo(<em>bool</em> $flag): <em>int</em> {
8284
$callback = function(<em>bool</em> $isValid): <em>int</em> {
83-
return $isValid ? 10 : 5;
8485
};
85-
86-
return $callback($flag);
8786
}
8887
]]>
8988
</code>
9089
<code title="❌ Invalid: Long name function/method/closure types">
9190
<![CDATA[
9291
function foo(<em>boolean</em> $flag): <em>integer</em> {
9392
$callback = function(<em>boolean</em> $isValid): <em>integer</em> {
94-
return $isValid ? 10 : 5;
9593
};
96-
97-
return $callback($flag);
9894
}
9995
]]>
10096
</code>
@@ -103,14 +99,12 @@ function foo(<em>boolean</em> $flag): <em>integer</em> {
10399
<code title="✔️ Valid: Short name nullable and union types">
104100
<![CDATA[
105101
function foo(?<em>bool</em> $flag, <em>bool</em>|string $var): ?<em>int</em> {
106-
return $flag ? 10 : null;
107102
}
108103
]]>
109104
</code>
110105
<code title="❌ Invalid: Long name nullable and union types">
111106
<![CDATA[
112107
function foo(?<em>boolean</em> $flag, <em>boolean</em>|string $var): ?<em>integer</em> {
113-
return $flag ? 10 : null;
114108
}
115109
]]>
116110
</code>

0 commit comments

Comments
 (0)