100 lines
No EOL
5.1 KiB
JSON
100 lines
No EOL
5.1 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "e72640a6-32b1-44a0-94f1-befd523a72dc"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-04-21T01:21:56+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": "Camel-case or snake-case for Drupal code?\n"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2023-04-19T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-04-21T01:21:56+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2023\/04\/19\/camel-case-or-snake-case-for-drupal-code",
|
|
"langcode": null
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>For some time, <a href=\"https:\/\/www.drupal.org\/docs\/develop\/standards\/php\/php-coding-standards#s-functions-and-variables\">Drupal's PHP coding standards<\/a> allows for writing variables in either snake-case (e.g. <code>$my_variable<\/code>) or lower camel-case (<code>e.g. $myVariable<\/code>).<\/p>\n\n<p>It originally only allowed for snake-case variable names but once it accepted both, I switched to camel-case as my default.<\/p>\n\n<p>Why? I didn't like the inconsistency of using one approach for variable names and one for method and property names in PHP classes (which were always camel-case).<\/p>\n\n<p>I'd have had code like this with a mixture of both:<\/p>\n\n<pre><code class=\"language-php\">class MyClass {\n\n private EntityTypeManagerInterface $entityTypeManager;\n\n public function __construct(EntityTypeManagerInterface $entity_type_manager) {\n $this->entityTypeManager = $entity_type_manager;\n }\n\n}\n<\/code><\/pre>\n\n<p>Or even more simply:<\/p>\n\n<pre><code class=\"language-php\">$entity_type_manager = \\Drupal::entityTypeManager();\n<\/code><\/pre>\n\n<p>I prefer not to have to consistently think about which to use and, if possible, like to use standard approaches in different codebases whether I'm working on a Drupal project, a Symfony project, or a PHP library.<\/p>\n\n<p>Plus, I get to use new PHP features like <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2023\/04\/12\/cleaner-php-code-with-promoted-constructor-properties\">promoted constructor properties<\/a> if everything is named in the same format.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>For some time, <a href=\"https:\/\/www.drupal.org\/docs\/develop\/standards\/php\/php-coding-standards#s-functions-and-variables\">Drupal's PHP coding standards<\/a> allows for writing variables in either snake-case (e.g. <code>$my_variable<\/code>) or lower camel-case (<code>e.g. $myVariable<\/code>).<\/p>\n\n<p>It originally only allowed for snake-case variable names but once it accepted both, I switched to camel-case as my default.<\/p>\n\n<p>Why? I didn't like the inconsistency of using one approach for variable names and one for method and property names in PHP classes (which were always camel-case).<\/p>\n\n<p>I'd have had code like this with a mixture of both:<\/p>\n\n<pre><code class=\"language-php\">class MyClass {\n\n private EntityTypeManagerInterface $entityTypeManager;\n\n public function __construct(EntityTypeManagerInterface $entity_type_manager) {\n $this->entityTypeManager = $entity_type_manager;\n }\n\n}\n<\/code><\/pre>\n\n<p>Or even more simply:<\/p>\n\n<pre><code class=\"language-php\">$entity_type_manager = \\Drupal::entityTypeManager();\n<\/code><\/pre>\n\n<p>I prefer not to have to consistently think about which to use and, if possible, like to use standard approaches in different codebases whether I'm working on a Drupal project, a Symfony project, or a PHP library.<\/p>\n\n<p>Plus, I get to use new PHP features like <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2023\/04\/12\/cleaner-php-code-with-promoted-constructor-properties\">promoted constructor properties<\/a> if everything is named in the same format.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "2025-04-21T01:21:56+00:00",
|
|
"guid": null,
|
|
"hash": "0d32d809ef0473c3b8fd336040076cae",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |