File tree Expand file tree Collapse file tree 4 files changed +21
-19
lines changed Expand file tree Collapse file tree 4 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 22
33namespace HM \Sniffs ;
44
5+ use PHP_CodeSniffer \Files \File as PhpcsFile ;
56use PHP_CodeSniffer \Util ;
67
78trait ExtraSniffCode {
@@ -11,13 +12,14 @@ trait ExtraSniffCode {
1112 * This allows overriding an existing sniff and retaining the existing
1213 * ignore statements.
1314 *
15+ * @param PhpcsFile $file File being checked.
1416 * @param string $legacy Legacy sniff code
1517 */
16- protected function duplicate_ignores ( $ legacy ) {
18+ protected function duplicate_ignores ( PhpcsFile $ file , $ legacy ) {
1719 $ expression = sprintf ( '/^%s(\..+)?$/ ' , preg_quote ( $ legacy ) );
1820 $ base_code = Util \Common::getSniffCode ( get_class ( $ this ) );
1921
20- foreach ( $ this -> phpcsFile ->tokenizer ->ignoredLines as $ line => $ ignored ) {
22+ foreach ( $ file ->tokenizer ->ignoredLines as $ line => $ ignored ) {
2123 $ additional = [];
2224
2325 if ( empty ( $ ignored ) ) {
@@ -38,7 +40,7 @@ protected function duplicate_ignores( $legacy ) {
3840 }
3941
4042 if ( ! empty ( $ additional ) ) {
41- $ this -> phpcsFile ->tokenizer ->ignoredLines [ $ line ] = array_merge ( $ ignored , $ additional );
43+ $ file ->tokenizer ->ignoredLines [ $ line ] = array_merge ( $ ignored , $ additional );
4244 }
4345 }
4446
Original file line number Diff line number Diff line change @@ -56,13 +56,13 @@ public function __construct() {
5656 }
5757
5858 /**
59- * Override init to duplicate any ignores.
59+ * Override process to duplicate any ignores.
6060 *
61- * @param PhpcsFile $phpcsFile
61+ * @param PhpcsFile $file
62+ * @param int $stackPtr
6263 */
63- protected function init ( PhpcsFile $ phpcsFile ) {
64- parent ::init ( $ phpcsFile );
65-
66- $ this ->duplicate_ignores ( 'WordPress.Security.EscapeOutput ' );
64+ public function process ( PhpcsFile $ file , $ stackPtr ) {
65+ $ this ->duplicate_ignores ( $ file , 'WordPress.Security.EscapeOutput ' );
66+ return parent ::process ( $ file , $ stackPtr );
6767 }
6868}
Original file line number Diff line number Diff line change @@ -27,17 +27,17 @@ class NonceVerificationSniff extends WPCSNonceVerificationSniff {
2727 public $ allowQueryVariables = false ;
2828
2929 /**
30- * Override init to override config and duplicate any ignores.
30+ * Override process to override config and duplicate any ignores.
3131 *
3232 * @param PhpcsFile $phpcsFile
33+ * @param int $stackPtr
3334 */
34- public function init ( PhpcsFile $ file ) {
35- parent ::init ( $ file );
36-
35+ public function process ( PhpcsFile $ file , $ stackPtr ) {
3736 if ( $ this ->allowQueryVariables ) {
3837 unset( $ this ->superglobals [ '$_GET ' ] );
3938 }
4039
41- $ this ->duplicate_ignores ( 'WordPress.Security.NonceVerification ' );
40+ $ this ->duplicate_ignores ( $ file , 'WordPress.Security.NonceVerification ' );
41+ return parent ::process ( $ file , $ stackPtr );
4242 }
4343}
Original file line number Diff line number Diff line change @@ -36,14 +36,14 @@ class ValidatedSanitizedInputSniff extends WPCSValidatedSanitizedInputSniff {
3636 ];
3737
3838 /**
39- * Override init to duplicate any ignores.
39+ * Override process to duplicate any ignores.
4040 *
4141 * @param PhpcsFile $phpcsFile
42+ * @param int $stackPtr
4243 */
43- protected function init ( PhpcsFile $ phpcsFile ) {
44- parent ::init ( $ phpcsFile );
45-
46- $ this ->duplicate_ignores ( 'WordPress.Security.ValidatedSanitizedInput ' );
44+ public function process ( PhpcsFile $ file , $ stackPtr ) {
45+ $ this ->duplicate_ignores ( $ file , 'WordPress.Security.ValidatedSanitizedInput ' );
46+ return parent ::process ( $ file , $ stackPtr );
4747 }
4848
4949 /**
You can’t perform that action at this time.
0 commit comments