PHP 8.3
// 괄호 없으면 PHP Parse error:
$request = (new Request())->withMethod('GET')->withUri('/hello-world');
PHP 8.4
$request = new Request()->withMethod('GET')->withUri('/hello-world');
RFC 통과 각.
해당 RFC 통과로 가능해지는것들
쉽게 알기위해 var_dump 로 덤프뜰때를 표현하면
$myClass = MyClass::class; var_dump( new $myClass()::CONSTANT, // string(8) "constant" new $myClass()::$staticProperty, // string(14) "staticProperty" new $myClass()::staticMethod(), // string(12) "staticMethod" new $myClass()->property, // string(8) "property" new $myClass()->method(), // string(6) "method" new $myClass()(), // string(8) "__invoke" );
중간변수 필요하지 않을때는 이렇게 바로바로 할 수 있다는군요