Skip to content

Commit

Permalink
Added PSR-2 documentation XML files (#3832)
Browse files Browse the repository at this point in the history
Documentation for the following PSR2 sniffs:
* `PSR2.Files.ClosingTag`
* `PSR2.Methods.FunctionCallSignature`
* `PSR2.Methods.FunctionClosingBrace`
  • Loading branch information
blue32a authored Jul 11, 2023
1 parent 6067ef4 commit 22edcb3
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1378,9 +1378,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="SwitchDeclarationStandard.xml" role="php" />
</dir>
<dir name="Files">
<file baseinstalldir="PHP/CodeSniffer" name="ClosingTagStandard.xml" role="php" />
<file baseinstalldir="PHP/CodeSniffer" name="EndFileNewlineStandard.xml" role="php" />
</dir>
<dir name="Methods">
<file baseinstalldir="PHP/CodeSniffer" name="FunctionCallSignatureStandard.xml" role="php" />
<file baseinstalldir="PHP/CodeSniffer" name="FunctionClosingBraceStandard.xml" role="php" />
<file baseinstalldir="PHP/CodeSniffer" name="MethodDeclarationStandard.xml" role="php" />
</dir>
<dir name="Namespaces">
Expand Down
23 changes: 23 additions & 0 deletions src/Standards/PSR2/Docs/Files/ClosingTagStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<documentation title="Closing Tag">
<standard>
<![CDATA[
Checks that the file does not end with a closing tag.
]]>
</standard>
<code_comparison>
<code title="Valid: Closing tag not used.">
<![CDATA[
<?php
echo 'Foo';
<em></em>
]]>
</code>
<code title="Invalid: Closing tag used.">
<![CDATA[
<?php
echo 'Foo';
<em>?></em>
]]>
</code>
</code_comparison>
</documentation>
107 changes: 107 additions & 0 deletions src/Standards/PSR2/Docs/Methods/FunctionCallSignatureStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<documentation title="Function Call Signature">
<standard>
<![CDATA[
Checks that the function call format is correct.
]]>
</standard>
<code_comparison>
<code title="Valid: Correct spacing is used around parentheses.">
<![CDATA[
foo<em></em>(<em></em>$bar, $baz<em></em>);
]]>
</code>
<code title="Invalid: Incorrect spacing used, too much space around the parentheses.">
<![CDATA[
foo<em> </em>(<em> </em>$bar, $baz<em> </em>);
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Correct number of spaces used for indent in a multi-line function call.">
<![CDATA[
foo(
<em> </em>$bar,
<em> </em>$baz
);
]]>
</code>
<code title="Invalid: Incorrect number of spaces used for indent in a multi-line function call.">
<![CDATA[
foo(
<em> </em>$bar,
<em> </em>$baz
);
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Closing parenthesis for a multi-line function call is on a new line after the last parameter.">
<![CDATA[
foo(
$bar,
$baz
<em>)</em>;
]]>
</code>
<code title="Invalid: Closing parenthesis for a multi-line function call is not on a new line after the last parameter.">
<![CDATA[
foo(
$bar,
$baz<em>)</em>;
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: The first argument of a multi-line function call is on a new line.">
<![CDATA[
foo(
<em>$bar</em>,
$baz
);
]]>
</code>
<code title="Invalid: The first argument of a multi-line function call is not on a new line.">
<![CDATA[
foo(<em>$bar</em>,
$baz
);
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Only one argument per line in a multi-line function call.">
<![CDATA[
foo(
$bar,
<em>$baz</em>
);
]]>
</code>
<code title="Invalid: Two or more arguments per line in a multi-line function call.">
<![CDATA[
foo(
$bar, <em>$baz</em>
);
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: No blank lines in a multi-line function call.">
<![CDATA[
foo(
$bar,
$baz
);
]]>
</code>
<code title="Invalid: Blank line in multi-line function call.">
<![CDATA[
foo(
$bar,
<em></em>
$baz
);
]]>
</code>
</code_comparison>
</documentation>
26 changes: 26 additions & 0 deletions src/Standards/PSR2/Docs/Methods/FunctionClosingBraceStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<documentation title="Function Closing Brace">
<standard>
<![CDATA[
Checks that the closing brace of a function goes directly after the body.
]]>
</standard>
<code_comparison>
<code title="Valid: Closing brace directly follows the function body.">
<![CDATA[
function foo()
{
echo 'foo';
<em>}</em>
]]>
</code>
<code title="Invalid: Blank line between the function body and the closing brace.">
<![CDATA[
function foo()
{
echo 'foo';
<em></em>
<em>}</em>
]]>
</code>
</code_comparison>
</documentation>

0 comments on commit 22edcb3

Please sign in to comment.