From 977e3f2f63e3b253c7fc979ccb5bf135423a1d51 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 20 Aug 2023 03:23:44 +0200 Subject: [PATCH] Sniff: remove `init()` method As pointed out by GaryJones, as all utility methods have now been made self-contained, it is no longer necessary to have a separate `initi()` method in the `Sniff` class. --- WordPress/Sniff.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 369ecf0fc2..eaa7c22b55 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -52,7 +52,9 @@ abstract class Sniff implements PHPCS_Sniff { * normal file processing. */ public function process( File $phpcsFile, $stackPtr ) { - $this->init( $phpcsFile ); + $this->phpcsFile = $phpcsFile; + $this->tokens = $phpcsFile->getTokens(); + return $this->process_token( $stackPtr ); } @@ -67,21 +69,4 @@ public function process( File $phpcsFile, $stackPtr ) { * normal file processing. */ abstract public function process_token( $stackPtr ); - - /** - * Initialize the class for the current process. - * - * This method must be called by child classes before using many of the methods - * below. - * - * @since 0.4.0 - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file currently being processed. - * - * @return void - */ - protected function init( File $phpcsFile ) { - $this->phpcsFile = $phpcsFile; - $this->tokens = $phpcsFile->getTokens(); - } }