Skip to content

Commit d4d45fc

Browse files
Update coding style guidelines for function arguments
Clarified guidelines on function arguments and array usage.
1 parent fa31cb1 commit d4d45fc

File tree

1 file changed

+12
-7
lines changed
  • general/development/policies/codingstyle

1 file changed

+12
-7
lines changed

general/development/policies/codingstyle/index.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,20 +1161,24 @@ Magic methods are heavily discouraged, justification will be required when used.
11611161

11621162
### Using arrays for options as arguments
11631163

1164-
All arguments to a function should be explicitly listed out and defined with a type. Using arrays like this can result in error as the types are not enforced as well as leading to poor documentation of the function
1164+
All arguments to a function should be explicitly listed out and defined with a type. Using arrays like this can result in error as the types are not enforced as well as leading to poor documentation of the function.
11651165

11661166
<InvalidExample>
1167+
11671168
```php
1168-
public function badfunction(
1169-
string $text,
1170-
context $context = null,
1171-
array $options = [],
1172-
): string;
1173-
```
1169+
public function badfunction(
1170+
string $text,
1171+
context $context = null,
1172+
array $options = [],
1173+
): string;
1174+
```
1175+
11741176
</InvalidExample>
11751177

11761178
If arguments are optional, then they should be marked appropriately as optional with a default value.
1179+
11771180
<ValidExample>
1181+
11781182
```php
11791183
function goodfunction(
11801184
string $text,
@@ -1189,6 +1193,7 @@ If arguments are optional, then they should be marked appropriately as optional
11891193
bool $allowid = false,
11901194
): string;
11911195
```
1196+
11921197
</ValidExample>
11931198

11941199
If there was a very good reason, then the use of an array could be considered. But it is strongly encouraged that all parameters be explict and typed.

0 commit comments

Comments
 (0)