Skip to content

Commit

Permalink
Merge pull request #192 from PHPCSStandards/feature/psr12-controlstru…
Browse files Browse the repository at this point in the history
…cturespacing-minor-tweak

PSR12/ControlStructureSpacing: small tweak
  • Loading branch information
jrfnl authored Dec 26, 2023
2 parents 6be2da7 + 069331a commit a28917a
Showing 1 changed file with 19 additions and 3 deletions.
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

0 comments on commit a28917a

Please sign in to comment.