Skip to content

Commit

Permalink
Add test to check it also works with methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Nov 17, 2023
1 parent 0bc6e02 commit 4bea3f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ public function testFunctionDocBlockCanBeRead()
'@SuppressWarnings(PHPMD.NPathComplexity)',
), $lines);
}

public function testMethodDocBlockCanBeRead()
{
/** @var ASTFunction $function */
$function = $this->getFirstClassMethodForTestCase();

$lines = array_map(function ($line) {
return trim($line, " \t\n\r\0\x0B/*");
}, explode("\n", trim($function->getComment(), " \t\n\r\0\x0B/*")));

$this->assertSame(array(
'@SuppressWarnings(PHPMD.CyclomaticComplexity)',
'@SuppressWarnings(PHPMD.NPathComplexity)',
), $lines);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

class Foo
{
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function bar() {
if (true and true and false) return;
/** This comment breaks SuppressWarnings */
if (true and true and false) return;
if (true and true and false) return;
if (true and true and false) return;
}
}

0 comments on commit 4bea3f3

Please sign in to comment.