Immutable object: Difference between revisions

Content deleted Content added
m WP:ADOPTYPO boolean -> Boolean
Line 341:
}
1;
</syntaxhighlight>
 
=== PHP ===
In [[PHP]] have readonly properties since version 8.1 and readonly classes since version 8.2.<ref>https://www.php.net/releases/8.1/en.php#readonly_properties</ref><ref>https://www.php.net/releases/8.2/en.php#readonly_classes</ref>
 
<syntaxhighlight lang="php">
readonly class BlogData
{
public string $title;
 
public Status $status;
 
public function __construct(string $title, Status $status)
{
$this->title = $title;
$this->status = $status;
}
}
</syntaxhighlight>