<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>
<p>It originally only allowed for snake-case variable names but once it accepted both, I switched to camel-case as my default.</p>
<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>
<p>I'd have had code like this with a mixture of both:</p>
<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>
<p>Plus, I get to use new PHP features like <a href="/daily/2023/04/12/cleaner-php-code-with-promoted-constructor-properties">promoted constructor properties</a> if everything is named in the same format.</p>
format:full_html
processed:|
<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>
<p>It originally only allowed for snake-case variable names but once it accepted both, I switched to camel-case as my default.</p>
<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>
<p>I'd have had code like this with a mixture of both:</p>
<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>
<p>Plus, I get to use new PHP features like <a href="/daily/2023/04/12/cleaner-php-code-with-promoted-constructor-properties">promoted constructor properties</a> if everything is named in the same format.</p>