Closed
Description
I've gone through the PHP versions since 7.3 which was the most recently released when PSR-12 was accepted and gathered a list of syntax that we may want to cover in this PER. This list is likely incomplete so please add a comment if there's more I should add.
PHP 7.3: https://www.php.net/manual/en/migration73.php
- Add section describing nowdoc and heredoc #5 Heredoc / Nowdoc indention: https://3v4l.org/lTXHQ
-
Array destructuring: https://3v4l.org/85FjD - Add a section on trailing commas #18 Trailing commas in function / method calls:
foo(1, 2, 3,)
PHP 7.4: https://www.php.net/manual/en/migration74.php
- Update the abstract/final section to cover all modifier keywords #19 Class property types:
public int $foo;
- Add a section on short-lambdas #17 Short functions:
fn(int $foo) => $foo * 2
-
Numeric literal separator:$int = 1_000_000;
-
__serialize
and__unserialize
vs usingSerializable
-
Nested ternaries require parenthesis in some situations post 7.4, we should consider usingSHOULD NOT
for nested ternaries.
PHP 8.0: https://www.php.net/manual/en/migration80.php
- Describe named arguments. #42 Named Arguments:
foo(1, c: 2)
https://3v4l.org/tglTA - Add Attributes style guide #26 Attributes: https://3v4l.org/veQIX
-
Constructor property promotion: https://3v4l.org/2hirZ - Add handling for compound types. #45 Union types:
Foo|Baz
vsFoo | Baz
- Add match section #21 Match expressions: https://3v4l.org/2s8uK
-
Throw as expression:$a = $b ?: throw Exception('b is falsy');
- Add a section on trailing commas #18 Trailing comma in parameter list: https://3v4l.org/RGf19
-
FILTER_VALIDATE_BOOL
overFILTER_VALIDATE_BOOLEAN
when usingfilter_var
PHP 8.1: https://www.php.net/manual/en/migration81.php
-
Array unpacking with string keys:$array = [...$otherData, 'b' => 1];
-
Named arguments used after argument unpacking:$result = foo(...$args, namedArg: 123)
https://3v4l.org/PN7kg - Add section on enumerations. #7 Enums: https://3v4l.org/8Dljv
- First class callables:
foo(...)
vsfoo( ... )
- Add handling for compound types. #45 Intersection types:
Foo&Bar
vsFoo & Bar
-
new
keyword in parameter initializers: https://3v4l.org/vcqT5 - Update the abstract/final section to cover all modifier keywords #19 Readonly properties
PHP 8.2: https://github.com/php/php-src/milestone/4
Extra potential things to cover:
- Visibility keyword is not required when specifying
readonly
:public function __construct(readonly $foo)