-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHPCS: Add XML based sniff documentation (#146)
PHPCS: Add XML based sniff documentation
- Loading branch information
Showing
11 changed files
with
807 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Yoast/Docs/Commenting/CodeCoverageIgnoreDeprecatedStandard.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0"?> | ||
<documentation title="Code Coverage Ignore Deprecated"> | ||
<standard> | ||
<![CDATA[ | ||
Deprecated functions and methods should be ignored for code coverage calculations. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Function marked as deprecated has a @codeCoverageIgnore tag."> | ||
<![CDATA[ | ||
/** | ||
* <em>@deprecated x.x | ||
* @codeCoverageIgnore</em> | ||
*/ | ||
function deprecated_function() {} | ||
]]> | ||
</code> | ||
<code title="Invalid: Function marked as deprecated is missing a @codeCoverageIgnore tag."> | ||
<![CDATA[ | ||
/** | ||
* <em>@deprecated x.x</em> | ||
*/ | ||
function deprecated_function() {} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0"?> | ||
<documentation title="PHPUnit Covers Tag"> | ||
<standard> | ||
<![CDATA[ | ||
The @covers tag used to annotate which code is coverage by a test should follow the specifications of PHPUnit with regards to the supported annotations. | ||
See: | ||
* https://phpunit.readthedocs.io/en/7.5/code-coverage-analysis.html#specifying-covered-code-parts | ||
* https://phpunit.readthedocs.io/en/7.5/annotations.html#covers | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Correct covers tag annotation."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* @covers <em>Class_Name::method_name</em> | ||
*/ | ||
function test_something() {} | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Incorrect covers tag annotation."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* @covers Class_Name::method_name<em>()</em> | ||
*/ | ||
function test_something() {} | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<standard> | ||
<![CDATA[ | ||
There should be no duplicate @covers tags for the same test. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Unique @covers tags."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* @covers Name\Space\function_name | ||
* @covers Class_Name | ||
*/ | ||
function test_something() {} | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Duplicate @covers tag."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* @covers Name\Space\function_name | ||
* @covers Class_Name | ||
* @covers <em>Name\Space\function_name</em> | ||
*/ | ||
function test_something() {} | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<standard> | ||
<![CDATA[ | ||
There should be not be both a @covers tag as well as a @coversNothing tag for the same test. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Either one or more @covers tags or a @coversNothing tag."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* <em>@covers ::globalFunction</em> | ||
*/ | ||
function test_something() {} | ||
/** | ||
* Testing... | ||
* | ||
* <em>@coversNothing</em> | ||
*/ | ||
function test_something_else() {} | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Both a @covers tag as well as a @coversNothing tag."> | ||
<![CDATA[ | ||
class Some_Test extends TestCase { | ||
/** | ||
* Testing... | ||
* | ||
* <em>@coversNothing | ||
* @covers ::globalFunction</em> | ||
*/ | ||
function test_something() {} | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
<?xml version="1.0"?> | ||
<documentation title="File Comment"> | ||
<standard> | ||
<![CDATA[ | ||
A file containing a (named) namespace declaration does not need a file docblock. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Start of a namespaced file without a file docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em>namespace Yoast\A\B;</em> | ||
/** | ||
* Class docblock. | ||
*/ | ||
class { | ||
... | ||
]]> | ||
</code> | ||
<code title="Invalid: Start of a namespaced file with a file docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em>/** | ||
* File comment. | ||
*/ | ||
namespace Yoast\A\B;</em> | ||
/** | ||
* Class docblock. | ||
*/ | ||
class { | ||
... | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
A non-namespaced file must have a file docblock. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Start of a non-namespaced file with a file docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em>/** | ||
* File comment. | ||
*/</em> | ||
/** | ||
* Class docblock. | ||
*/ | ||
class { | ||
... | ||
]]> | ||
</code> | ||
<code title="Invalid: Start of a non-namespaced file missing a file docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em></em> | ||
/** | ||
* Class docblock. | ||
*/ | ||
class { | ||
... | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
A file comment should be a docblock. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: File docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em>/** | ||
* File comment. | ||
*/</em> | ||
]]> | ||
</code> | ||
<code title="Invalid: File comment is not a docblock."> | ||
<![CDATA[ | ||
<?php | ||
<em>/*</em> | ||
* File comment. | ||
*/ | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
There must be no blank lines before the file comment. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: No blank line between the PHP open tag and the file comment."> | ||
<![CDATA[ | ||
<?php<em> | ||
</em>/** | ||
* File comment. | ||
*/ | ||
]]> | ||
</code> | ||
<code title="Invalid: Blank line(s) between the PHP open tag and the file comment."> | ||
<![CDATA[ | ||
<?php<em> | ||
</em>/** | ||
* File comment. | ||
*/ | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
There must be exactly one blank line after the file comment. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: One blank line after file comment."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
*/<em> | ||
</em>echo $something; | ||
]]> | ||
</code> | ||
<code title="Invalid: No blank line or more than one blank line after file comment."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
*/<em> | ||
</em>echo $something; | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
A file comment must contain a @package tag. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: File comment containing the @package tag."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
* | ||
* <em>@package Yoast\Package</em> | ||
*/ | ||
]]> | ||
</code> | ||
<code title="Invalid: File comment missing the @package tag."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
*/ | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
<standard> | ||
<![CDATA[ | ||
A file comment @package tag must have a package name. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: File comment @package tag with a package name."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
* | ||
* <em>@package Yoast\Package</em> | ||
*/ | ||
]]> | ||
</code> | ||
<code title="Invalid: File comment @package tag without a package name."> | ||
<![CDATA[ | ||
<?php | ||
/** | ||
* File comment. | ||
* | ||
* <em>@package</em> | ||
*/ | ||
]]> | ||
</code> | ||
</code_comparison> | ||
|
||
</documentation> |
Oops, something went wrong.