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
Copy file name to clipboardExpand all lines: general/development/policies/codingstyle/index.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1161,20 +1161,24 @@ Magic methods are heavily discouraged, justification will be required when used.
1161
1161
1162
1162
### Using arrays for options as arguments
1163
1163
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.
1165
1165
1166
1166
<InvalidExample>
1167
+
1167
1168
```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
+
1174
1176
</InvalidExample>
1175
1177
1176
1178
If arguments are optional, then they should be marked appropriately as optional with a default value.
1179
+
1177
1180
<ValidExample>
1181
+
1178
1182
```php
1179
1183
function goodfunction(
1180
1184
string $text,
@@ -1189,6 +1193,7 @@ If arguments are optional, then they should be marked appropriately as optional
1189
1193
bool $allowid = false,
1190
1194
): string;
1191
1195
```
1196
+
1192
1197
</ValidExample>
1193
1198
1194
1199
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