Skip to content
Snippets Groups Projects
Commit 2a4dbff9 authored by Nikolay Lobachev's avatar Nikolay Lobachev Committed by Klaus Purer
Browse files

fix(UnusedPrivateMethod): Allow private constructor methods (#3079227)

parent c8664dfc
Branches
Tags
No related merge requests found
......@@ -55,6 +55,10 @@ class UnusedPrivateMethodSniff extends AbstractScopeSniff
$tokens = $phpcsFile->getTokens();
$methodName = $phpcsFile->getDeclarationName($stackPtr);
if ($methodName === '__construct') {
return;
}
$classPtr = key($tokens[$stackPtr]['conditions']);
// Search for direct $this->methodCall() or indirect callbacks [$this,
......
......@@ -2,6 +2,13 @@
class Test {
/**
* Private constructor in case class can be instantiated.
*/
private function __construct() {
}
/**
* Method is not called from anywhere in the class.
*/
......
......@@ -33,7 +33,7 @@ class UnusedPrivateMethodUnitTest extends CoderSniffUnitTest
*/
protected function getWarningList()
{
return [8 => 1];
return [15 => 1];
}//end getWarningList()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment