oliverdavies.uk/content/node.9d0e577d-eca2-4b05-9266-00f94901ae69.json

91 lines
No EOL
3.5 KiB
JSON

{
"uuid": [
{
"value": "9d0e577d-eca2-4b05-9266-00f94901ae69"
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "daily_email",
"target_type": "node_type",
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
}
],
"revision_timestamp": [
{
"value": "2025-05-11T09:00:44+00:00"
}
],
"revision_uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"revision_log": [],
"status": [
{
"value": true
}
],
"uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"title": [
{
"value": "Refactoring with readonly classes in PHP 8.2\n"
}
],
"created": [
{
"value": "2023-04-16T00:00:00+00:00"
}
],
"changed": [
{
"value": "2025-05-11T09:00:44+00:00"
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2023\/04\/16\/refactoring-with-readonly-classes-in-php-8-2",
"langcode": "en"
}
],
"body": [
{
"value": "\n <p>Marian Kostadinov (<a href=\"https:\/\/twitter.com\/stochnagara\">stochnagara on Twitter<\/a>) replied to Friday's email about DTOs and value objects to tell me about <code>readonly<\/code> classes, which can be done in PHP 8.2.<\/p>\n\n<p>Looking at the previous class:<\/p>\n\n<pre><code class=\"language-php\">class AccountDetails {\n\n public function __construct(\n public readonly string $accountNumber,\n public readonly string $sortCode,\n ) {}\n\n}\n<\/code><\/pre>\n\n<p>Instead of setting each property as <code>readonly<\/code>, the whole class can instead be marked as <code>readonly<\/code>:<\/p>\n\n<pre><code class=\"language-php\">readonly class AccountDetails {\n\n public function __construct(\n public string $accountNumber,\n public string $sortCode,\n ) {}\n\n}\n<\/code><\/pre>\n\n<p>Thanks for the suggestion, Marian!<\/p>\n\n ",
"format": "full_html",
"processed": "\n <p>Marian Kostadinov (<a href=\"https:\/\/twitter.com\/stochnagara\">stochnagara on Twitter<\/a>) replied to Friday's email about DTOs and value objects to tell me about <code>readonly<\/code> classes, which can be done in PHP 8.2.<\/p>\n\n<p>Looking at the previous class:<\/p>\n\n<pre><code class=\"language-php\">class AccountDetails {\n\n public function __construct(\n public readonly string $accountNumber,\n public readonly string $sortCode,\n ) {}\n\n}\n<\/code><\/pre>\n\n<p>Instead of setting each property as <code>readonly<\/code>, the whole class can instead be marked as <code>readonly<\/code>:<\/p>\n\n<pre><code class=\"language-php\">readonly class AccountDetails {\n\n public function __construct(\n public string $accountNumber,\n public string $sortCode,\n ) {}\n\n}\n<\/code><\/pre>\n\n<p>Thanks for the suggestion, Marian!<\/p>\n\n ",
"summary": null
}
]
}