Skip to content

Commit

Permalink
Add documentation for WordPress.NamingConventions.ValidVariableName (#…
Browse files Browse the repository at this point in the history
…2457)

* Add documentation for WordPress.NamingConventions.ValidVariableName

---------

Co-authored-by: Juliette <[email protected]>
  • Loading branch information
richardkorthuis and jrfnl authored Feb 12, 2025
1 parent c028f32 commit eb39475
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions WordPress/Docs/NamingConventions/ValidVariableNameStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Valid Variable Name"
>
<standard>
<![CDATA[
Use lowercase letters in variable names. Separate words using underscores.
]]>
</standard>
<code_comparison>
<code title="Valid: Lowercase variable name.">
<![CDATA[
<em>$prefix_variable_name</em> = 'value';
echo <em>$prefix_variable_name</em>;
]]>
</code>
<code title="Invalid: Mixed case function name.">
<![CDATA[
<em>$Prefix_Variable_NAME</em> = 'value';
echo <em>$Prefix_Variable_NAME</em>;
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Words separated by underscores.">
<![CDATA[
class My_Class {
public <em>$property_name</em> = 'value';
}
]]>
</code>
<code title="Invalid: Using camel case to separate words.">
<![CDATA[
class My_Class {
public <em>$propertyName</em> = 'value';
}
]]>
</code>
</code_comparison>
</documentation>

0 comments on commit eb39475

Please sign in to comment.