1111
1212use PHP_CodeSniffer \Files \File ;
1313use PHP_CodeSniffer \Sniffs \Sniff ;
14- use PHP_CodeSniffer \Standards \PSR2 \Sniffs \ControlStructures \ControlStructureSpacingSniff as PSR2Spacing ;
14+ use PHP_CodeSniffer \Standards \PSR2 \Sniffs \ControlStructures \ControlStructureSpacingSniff as PSR2ControlStructureSpacing ;
1515use PHP_CodeSniffer \Util \Tokens ;
1616
1717class ControlStructureSpacingSniff implements Sniff
@@ -24,6 +24,23 @@ class ControlStructureSpacingSniff implements Sniff
2424 */
2525 public $ indent = 4 ;
2626
27+ /**
28+ * Instance of the PSR2 ControlStructureSpacingSniff sniff.
29+ *
30+ * @var \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff
31+ */
32+ private $ psr2ControlStructureSpacing ;
33+
34+
35+ /**
36+ * Constructor.
37+ */
38+ public function __construct ()
39+ {
40+ $ this ->psr2ControlStructureSpacing = new PSR2ControlStructureSpacing ();
41+
42+ }//end __construct()
43+
2744
2845 /**
2946 * Returns an array of tokens this test wants to listen for.
@@ -70,8 +87,7 @@ public function process(File $phpcsFile, $stackPtr)
7087
7188 if ($ tokens [$ parenOpener ]['line ' ] === $ tokens [$ parenCloser ]['line ' ]) {
7289 // Conditions are all on the same line, so follow PSR2.
73- $ sniff = new PSR2Spacing ();
74- return $ sniff ->process ($ phpcsFile , $ stackPtr );
90+ return $ this ->psr2ControlStructureSpacing ->process ($ phpcsFile , $ stackPtr );
7591 }
7692
7793 $ next = $ phpcsFile ->findNext (T_WHITESPACE , ($ parenOpener + 1 ), $ parenCloser , true );
0 commit comments