91 lines
No EOL
3.4 KiB
JSON
91 lines
No EOL
3.4 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "e2991eb4-1aee-4d04-9045-989159a9b64f"
|
|
}
|
|
],
|
|
"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:14+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": "Strict typing in PHP"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2024-05-04T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-05-11T09:00:14+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2024\/05\/04\/strict-typing-in-php",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>I prefer writing and working with strictly typed code.<\/p>\n\n<p>One of the major improvements in PHP has been the option to enable strict types.<\/p>\n\n<p>For example, this code will usually not error and give the result:<\/p>\n\n<pre><code class=\"php\">function add(int $a, int $b): void\n{\n var_dump($a + $b);\n}\n\nadd(1, '1');\n<\/code><\/pre>\n\n<p>However, I'd prefer if it failed as I'm passing the function an integer and a string, but specifying they should both be integers.<\/p>\n\n<p>Fixing this is simple, by adding this line to the top of the file:<\/p>\n\n<pre><code class=\"php\">declare(strict_types=1);\n<\/code><\/pre>\n\n<p>I add this to every PHP file by default.<\/p>\n\n<p>I want my code to be as strict and predictable as possible, and to error when I want it to and make any bugs more explicit and easier to find and fix.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>I prefer writing and working with strictly typed code.<\/p>\n\n<p>One of the major improvements in PHP has been the option to enable strict types.<\/p>\n\n<p>For example, this code will usually not error and give the result:<\/p>\n\n<pre><code class=\"php\">function add(int $a, int $b): void\n{\n var_dump($a + $b);\n}\n\nadd(1, '1');\n<\/code><\/pre>\n\n<p>However, I'd prefer if it failed as I'm passing the function an integer and a string, but specifying they should both be integers.<\/p>\n\n<p>Fixing this is simple, by adding this line to the top of the file:<\/p>\n\n<pre><code class=\"php\">declare(strict_types=1);\n<\/code><\/pre>\n\n<p>I add this to every PHP file by default.<\/p>\n\n<p>I want my code to be as strict and predictable as possible, and to error when I want it to and make any bugs more explicit and easier to find and fix.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
]
|
|
} |