Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento2\Sniffs\CodeAnalysis;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff;

/**
Expand All @@ -25,4 +26,17 @@ public function register()
]
);
}
/**
* @inheritDoc
*/
public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === T_FUNCTION &&
strpos($phpcsFile->getDeclarationName($stackPtr), 'around') === 0) {
return;
}

parent::process($phpcsFile, $stackPtr);
}//end process()
}
2 changes: 2 additions & 0 deletions Magento2/Tests/CodeAnalysis/EmptyBlockUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ if (true) {} elseif (false) {}
function emptyFunction () { /*Empty function block*/ }

function nonEmptyFunction () { return true; }

function aroundEmptyFunction ($foo, $bar) { }