Skip to content

Commit

Permalink
Merge pull request #345 from Yoast/JRF/yoastcs-namespacename-various-…
Browse files Browse the repository at this point in the history
…improvements

NamingConventions/NamespaceName: new "missing prefix" error, bug fix and other improvements
  • Loading branch information
jrfnl authored Nov 20, 2023
2 parents 7ce39da + d2837d1 commit 9d4841e
Show file tree
Hide file tree
Showing 20 changed files with 382 additions and 232 deletions.
25 changes: 23 additions & 2 deletions Yoast/Docs/NamingConventions/NamespaceNameStandard.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Namespace Name Depth"
title="Namespace Name"
>
<standard>
<![CDATA[
A namespace name is expected to start with a package specific prefix.
Valid prefix(es) can be passed via a custom ruleset.
]]>
</standard>
<code_comparison>
<code title="Valid: namespace starting with a package specific prefix.">
<![CDATA[
namespace <em>Yoast\WP\Plugin\Admin\Forms</em>;
]]>
</code>
<code title="Invalid: namespace missing a package specific prefix.">
<![CDATA[
namespace <em>Admin\Forms</em>;
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
A namespace name is not allowed to be more than 3 levels deep (excluding the prefix).
It is recommended for the name to be two levels.
For unit test files, `Tests\(Doubles\)` will be regarded as part of the prefix for this check.
For unit test files, `Tests\(Unit|WP)\(Doubles\)` will be regarded as part of the prefix for this check.
]]>
</standard>
<code_comparison>
Expand All @@ -32,6 +51,8 @@ namespace Yoast\WP\Plugin\Tests\<em>Foo\Bar\Flo\Sub</em>;
<![CDATA[
The levels in a namespace name should reflect the path to the file.
If a path to name translation would result in an invalid namespace name based on the naming rules for PHP, an error will be thrown to rename the problem directory.
The plugin specific prefix is disregarded for this check.
]]>
</standard>
Expand Down
Loading

0 comments on commit 9d4841e

Please sign in to comment.