Skip to content

Commit eb39475

Browse files
Add documentation for WordPress.NamingConventions.ValidVariableName (#2457)
* Add documentation for WordPress.NamingConventions.ValidVariableName --------- Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
1 parent c028f32 commit eb39475

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0"?>
2+
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
4+
title="Valid Variable Name"
5+
>
6+
<standard>
7+
<![CDATA[
8+
Use lowercase letters in variable names. Separate words using underscores.
9+
]]>
10+
</standard>
11+
<code_comparison>
12+
<code title="Valid: Lowercase variable name.">
13+
<![CDATA[
14+
<em>$prefix_variable_name</em> = 'value';
15+
16+
echo <em>$prefix_variable_name</em>;
17+
]]>
18+
</code>
19+
<code title="Invalid: Mixed case function name.">
20+
<![CDATA[
21+
<em>$Prefix_Variable_NAME</em> = 'value';
22+
23+
echo <em>$Prefix_Variable_NAME</em>;
24+
]]>
25+
</code>
26+
</code_comparison>
27+
<code_comparison>
28+
<code title="Valid: Words separated by underscores.">
29+
<![CDATA[
30+
class My_Class {
31+
public <em>$property_name</em> = 'value';
32+
}
33+
]]>
34+
</code>
35+
<code title="Invalid: Using camel case to separate words.">
36+
<![CDATA[
37+
class My_Class {
38+
public <em>$propertyName</em> = 'value';
39+
}
40+
]]>
41+
</code>
42+
</code_comparison>
43+
</documentation>

0 commit comments

Comments
 (0)