Skip to content

Commit d6fc34b

Browse files
Ignore warning for empty around plugin
1 parent d24e023 commit d6fc34b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento2\Sniffs\CodeAnalysis;
77

8+
use PHP_CodeSniffer\Files\File;
89
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff;
910

1011
/**
@@ -25,4 +26,19 @@ public function register()
2526
]
2627
);
2728
}
29+
/**
30+
* @inheritDoc
31+
*/
32+
public function process(File $phpcsFile, $stackPtr)
33+
{
34+
$posOfFunction = $phpcsFile->findNext([T_FUNCTION], $stackPtr);
35+
$functionName = $phpcsFile->getDeclarationName($posOfFunction);
36+
// Skip for around function
37+
if (strpos($functionName, 'around') !== false) {
38+
return;
39+
}
40+
41+
parent::process($phpcsFile, $stackPtr);
42+
43+
}//end process()
2844
}

Magento2/Tests/CodeAnalysis/EmptyBlockUnitTest.inc

+4
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ if (true) {} elseif (false) {}
7474
function emptyFunction () { /*Empty function block*/ }
7575

7676
function nonEmptyFunction () { return true; }
77+
78+
function aroundEmptyFunction ($foo, $bar) {
79+
80+
}

0 commit comments

Comments
 (0)