Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for WordPress.NamingConventions.ValidVariableName #2457

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
51 changes: 51 additions & 0 deletions WordPress/Docs/NamingConventions/ValidVariableNameStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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';
]]>
</code>
<code title="Invalid: Mixed case function name.">
<![CDATA[
<em>$Prefix_Variable_NAME</em> = 'value';
]]>
</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>
<code_comparison>
<code title="Valid: Echo a correctly named variable.">
<![CDATA[
echo <em>$variable_name</em>;
]]>
</code>
<code title="Invalid: Echo an incorrectly named variable.">
<![CDATA[
echo <em>$VariableName</em>;
]]>
</code>
</code_comparison>
</documentation>
Loading