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: .github/instructions/php.instructions.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,6 +266,16 @@ See Manual:Coding conventions#Indenting and alignment.
266
266
267
267
For anonymous functions, prefer arrow functions when the anonymous function consists only of one line. Arrow functions are more concise and readable than regular anonymous functions and neatly side-steps formatting issues that arise with single-line anonymous functions.
268
268
269
+
### Type declarations for variables
270
+
Avoid using PHPDoc comments to declare types for local variables. Instead, use native type declarations for function parameters and return types, and use static analysis tools (like PHPStan or Psalm) to infer types of local variables.
271
+
272
+
Example:
273
+
274
+
```php
275
+
private static string $nameOfVariable = '';
276
+
```
277
+
278
+
269
279
### Type declarations in function parameters
270
280
271
281
Use native type declarations and return type declarations when applicable. (But see #Don't add type declarations for "big" legacy classes below.)
0 commit comments