-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: add documentation for Squiz.WhiteSpace.FunctionSpacing
- Loading branch information
Showing
1 changed file
with
185 additions
and
0 deletions.
There are no files selected for viewing
185 changes: 185 additions & 0 deletions
185
src/Standards/Squiz/Docs/WhiteSpace/FunctionSpacingStandard.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,185 @@ | ||
<documentation title="Function Spacing"> | ||
<standard> | ||
<![CDATA[ | ||
There should be exactly 2 blank lines before a function within a statement group or control structure when it is the first block of code. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Exactly 2 blank lines before the first function."> | ||
<![CDATA[ | ||
class MyClass | ||
{<em> | ||
</em> public function foo() { | ||
} | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Too few blank lines before the first function."> | ||
<![CDATA[ | ||
class MyClass | ||
{<em> | ||
</em> public function foo() { | ||
} | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<code_comparison> | ||
<code title="Valid: Exactly 2 blank lines before the first function."> | ||
<![CDATA[ | ||
if ($something) {<em> | ||
</em> function foo() { | ||
} | ||
function bar() { | ||
} | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Too many blank lines before the first function."> | ||
<![CDATA[ | ||
if ($something) {<em> | ||
</em> function foo() { | ||
} | ||
function bar() { | ||
} | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<standard> | ||
<![CDATA[ | ||
There should be exactly 2 blank lines before and after a function declaration. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Exactly 2 blank lines before and after function declarations."> | ||
<![CDATA[ | ||
interface MyInterface | ||
{ | ||
public function foo();<em> | ||
</em> public function bar();<em> | ||
</em> public function baz(); | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Incorrect number of blank lines before/after function declarations."> | ||
<![CDATA[ | ||
interface MyInterface | ||
{ | ||
public function foo();<em> | ||
</em> public function bar();<em> | ||
</em> public function baz(); | ||
} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<standard> | ||
<![CDATA[ | ||
There should be exactly two blank lines after a function within a statement group or control structure when it is the last block of code. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Exactly 2 blank lines after the last function."> | ||
<![CDATA[ | ||
trait MyTrait | ||
{ | ||
public function foo() { | ||
} | ||
public function bar() { | ||
}<em> | ||
</em>} | ||
]]> | ||
</code> | ||
<code title="Invalid: Too few blank lines after the last function."> | ||
<![CDATA[ | ||
trait MyTrait | ||
{ | ||
public function foo() { | ||
} | ||
public function bar() { | ||
}<em> | ||
</em>} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<code_comparison> | ||
<code title="Valid: Exactly 2 blank lines after the last function."> | ||
<![CDATA[ | ||
if ($something) { | ||
function foo() { | ||
} | ||
function bar() { | ||
}<em> | ||
</em>} | ||
]]> | ||
</code> | ||
<code title="Invalid: Too many blank lines after the last function."> | ||
<![CDATA[ | ||
if ($something) { | ||
function foo() { | ||
} | ||
function bar() { | ||
}<em> | ||
</em>} | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |