3232 */
3333class VariableInDoubleQuotedStringSniff implements Sniff
3434{
35- /**
36- * The PHP_CodeSniffer object controlling this run.
37- *
38- * @var File
39- */
40- private $ phpCsFile ;
41-
4235 /**
4336 * Registers the tokens that this sniff wants to listen for.
4437 *
@@ -67,8 +60,6 @@ public function register(): array
6760 */
6861 public function process (File $ phpcsFile , $ stackPtr ): void
6962 {
70- $ this ->phpCsFile = $ phpcsFile ;
71-
7263 $ varRegExp = '/\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/ ' ;
7364
7465 $ tokens = $ phpcsFile ->getTokens ();
@@ -104,7 +95,7 @@ public function process(File $phpcsFile, $stackPtr): void
10495 }
10596 }
10697
107- $ fix = $ this -> phpCsFile ->addFixableError (
98+ $ fix = $ phpcsFile ->addFixableError (
10899 \sprintf (
109100 'must surround variable %s with { } ' ,
110101 $ var
@@ -122,7 +113,8 @@ public function process(File $phpcsFile, $stackPtr): void
122113 $ pos ,
123114 $ var
124115 );
125- $ this ->fixPhpCsFile ($ stackPtr , $ correctVariable );
116+
117+ $ this ->fixPhpCsFile ($ stackPtr , $ correctVariable , $ phpcsFile );
126118 }
127119 }
128120 }
@@ -149,13 +141,12 @@ private function surroundVariableWithBraces(string $content, int $pos, string $v
149141 *
150142 * @param int $stackPtr stack pointer
151143 * @param string $correctVariable correct variable
144+ * @param File $phpCsFile PHP_CodeSniffer File object
152145 *
153146 * @return void
154147 */
155- private function fixPhpCsFile (int $ stackPtr , string $ correctVariable ): void
148+ private function fixPhpCsFile (int $ stackPtr , string $ correctVariable, File $ phpCsFile ): void
156149 {
157- $ phpCsFile = $ this ->phpCsFile ;
158-
159150 $ phpCsFile ->fixer ->beginChangeset ();
160151 $ phpCsFile ->fixer ->replaceToken ($ stackPtr , $ correctVariable );
161152 $ phpCsFile ->fixer ->endChangeset ();
0 commit comments