Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
In PHP 8.2 class declaration can be prefixed with the readonly keyword. Thus, all properties of the class will be readonly. So you don't need to add the read only keyword to any property in this class.
readonly class Post
{
public function __construct(
public string $title,
public Author $author,
public string $body,
public DateTime $publishedAt,
) {}
}
Our parser will fail on this syntax because we do not allow the readonly keyword before the class keyword.
There will be no effect on any rule.
Activity
Done
Pinned fields
Click on the next to a field label to start pinning.
In PHP 8.2 class declaration can be prefixed with the
readonly
keyword. Thus, all properties of the class will be readonly. So you don't need to add the read only keyword to any property in this class.readonly class Post { public function __construct( public string $title, public Author $author, public string $body, public DateTime $publishedAt, ) {} }
Our parser will fail on this syntax because we do not allow the
readonly
keyword before theclass
keyword.There will be no effect on any rule.