Skip to content

Commit

Permalink
Merge pull request #35 from Zenify/method-getter-docblock
Browse files Browse the repository at this point in the history
FunctionComment sniff enabled [closes #30]
  • Loading branch information
Tomáš Votruba committed Oct 26, 2015
2 parents f177ab5 + 4663627 commit e3786e7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ZenifyCodingStandard/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>

<!-- Commenting -->
<rule ref="Squiz.Commenting.FunctionComment"/>
<rule ref="Squiz.Commenting.VariableComment"/>

<!-- ControlStructures -->
Expand Down
4 changes: 2 additions & 2 deletions tests/CodeSnifferRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function getErrorCountInFile($source)
* @param string $name
* @return string
*/
public function detectRulesetFromSniffName($sniff)
public function detectRulesetFromSniffName($name)
{
$standard = $this->detectStandardFromSniffName($sniff);
$standard = $this->detectStandardFromSniffName($name);

if (isset($this->standardRulesets[$standard])) {
return $this->standardRulesets[$standard];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Zenify\CodingStandard\Tests\Squiz\Commenting\VariableComment;

use PHPUnit_Framework_TestCase;
use Zenify\CodingStandard\Tests\CodeSnifferRunner;


/**
* @covers Squiz_Sniffs_Commenting_FunctionCommentSniff
*/
final class FunctionCommentSniffTest extends PHPUnit_Framework_TestCase
{

public function testDetection()
{
$codeSnifferRunner = new CodeSnifferRunner('Squiz.Commenting.FunctionComment');

$this->assertSame(1, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/wrong.php'));
$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct.php'));
}

}
17 changes: 17 additions & 0 deletions tests/Squiz/Commenting/FunctionComment/correct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace SomeNamespace;


class SomeClass
{

/**
* @return string
*/
public function getSome()
{
return 'some';
}

}
13 changes: 13 additions & 0 deletions tests/Squiz/Commenting/FunctionComment/wrong.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SomeNamespace;


class SomeClass
{

public function getSome()
{
}

}

0 comments on commit e3786e7

Please sign in to comment.