[code]
// 괄호를 사용한 기존 방식
$request = (new Request())->withMethod('GET')->withUri('/hello-world');
// PHP Parse error (<= PHP 8.3): syntax error, unexpected token "->"
$request = new Request()->withMethod('GET')->withUri('/hello-world');
[/code]
8.4 부터 아래와 같은 표현이 가능합니다.
[code]
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"
);
[/code]
참고(영문): https://laravel-news.com/php-8-4-class-instantiation-without-extra-parenthesis
댓글 3개
게시글 목록
| 번호 | 제목 |
|---|---|
| 1874 | |
| 1873 | |
| 1870 | |
| 1862 | |
| 1846 | |
| 1845 | |
| 1837 | |
| 1835 | |
| 1823 | |
| 1787 | |
| 1781 | |
| 1777 | |
| 1771 | |
| 1750 | |
| 1746 | |
| 1743 | |
| 1742 | |
| 1738 | |
| 1714 | |
| 1710 | |
| 1700 | |
| 1699 | |
| 1696 | |
| 1694 | |
| 1691 | |
| 1684 | |
| 1662 | |
| 1659 | |
| 1656 | |
| 1637 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기