Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff as PSR2Spacing;
use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff as PSR2ControlStructureSpacing;
use PHP_CodeSniffer\Util\Tokens;

class ControlStructureSpacingSniff implements Sniff
Expand All @@ -24,6 +24,23 @@ class ControlStructureSpacingSniff implements Sniff
*/
public $indent = 4;

/**
* Instance of the PSR2 ControlStructureSpacingSniff sniff.
*
* @var \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff
*/
private $psr2ControlStructureSpacing;


/**
* Constructor.
*/
public function __construct()
{
$this->psr2ControlStructureSpacing = new PSR2ControlStructureSpacing();

}//end __construct()


/**
* Returns an array of tokens this test wants to listen for.
Expand Down Expand Up @@ -70,8 +87,7 @@ public function process(File $phpcsFile, $stackPtr)

if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) {
// Conditions are all on the same line, so follow PSR2.
$sniff = new PSR2Spacing();
return $sniff->process($phpcsFile, $stackPtr);
return $this->psr2ControlStructureSpacing->process($phpcsFile, $stackPtr);
}

$next = $phpcsFile->findNext(T_WHITESPACE, ($parenOpener + 1), $parenCloser, true);
Expand Down