Skip to content

Commit

Permalink
Return Type Sniff should ignore abstract functions and interfaces, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xalopp authored and djoos committed Jan 16, 2019
1 parent 8477dc3 commit 406a1db
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Symfony/Sniffs/Functions/ReturnTypeSniff.php
Expand Up @@ -68,6 +68,10 @@ public function process(File $phpcsFile, $stackPtr)
$next = $stackPtr;

do {
if (!isset($tokens[$stackPtr]['scope_closer'])) {
break;
}

$next = $phpcsFile->findNext(
T_RETURN,
$next + 1,
Expand Down
20 changes: 20 additions & 0 deletions Symfony/Tests/Functions/ReturnTypeUnitTest.inc
Expand Up @@ -29,3 +29,23 @@ function omg(): void
}
};
}

interface FooInterface
{
public function fooMixed();

public function voidFoo(): void;
}

abstract class AbstractFoo
{
public function fooMixed();

public function voidFoo(): void;

public function fail(): void
{
return null;
}
}

1 change: 1 addition & 0 deletions Symfony/Tests/Functions/ReturnTypeUnitTest.php
Expand Up @@ -45,6 +45,7 @@ public function getErrorList()
return array(
5 => 1,
21 => 1,
48 => 1,
);
}

Expand Down

0 comments on commit 406a1db

Please sign in to comment.