diff --git a/WPForms/Sniffs/BaseSniff.php b/WPForms/Sniffs/BaseSniff.php index df9c1dd..ab845a0 100644 --- a/WPForms/Sniffs/BaseSniff.php +++ b/WPForms/Sniffs/BaseSniff.php @@ -241,17 +241,17 @@ protected function getFullyQualifiedClassName( $phpcsFile ) { * * @since 1.0.2 * - * @param string $class Class name. + * @param string $className Class name. * * @return string */ - private function convertClassName( $class ) { + private function convertClassName( $className ) { - if ( strpos( $class, '_' ) !== false ) { - return strtolower( $class ); + if ( strpos( $className, '_' ) !== false ) { + return strtolower( $className ); } - return $this->camelToSnake( $class ); + return $this->camelToSnake( $className ); } /** @@ -259,12 +259,12 @@ private function convertClassName( $class ) { * * @since 1.0.2 * - * @param string $string A string. + * @param string $s A string. * * @return string */ - private function camelToSnake( $string ) { + private function camelToSnake( $s ) { - return strtolower( preg_replace( [ '/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/' ], '$1_$2', $string ) ); + return strtolower( preg_replace( [ '/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/' ], '$1_$2', $s ) ); } } diff --git a/WPForms/Sniffs/Comments/ParamTagHooksSniff.php b/WPForms/Sniffs/Comments/ParamTagHooksSniff.php index 8211665..db2d7ce 100644 --- a/WPForms/Sniffs/Comments/ParamTagHooksSniff.php +++ b/WPForms/Sniffs/Comments/ParamTagHooksSniff.php @@ -123,32 +123,32 @@ private function countArguments( $phpcsFile, $stackPtr ) { // phpcs:ignore Gener while ( $currentPosition < $lastPosition ) { if ( $tokens[ $currentPosition ]['code'] === T_WHITESPACE ) { - $currentPosition ++; + ++$currentPosition; continue; } if ( $tokens[ $currentPosition ]['code'] === T_COMMA ) { $lookingForComma = false; - $currentPosition ++; + ++$currentPosition; continue; } if ( in_array( $tokens[ $currentPosition ]['code'], [ T_ARRAY, T_OPEN_SHORT_ARRAY, T_CLOSURE ], true ) ) { - $quantity ++; + ++$quantity; } if ( $this->skip( $phpcsFile, $currentPosition ) ) { continue; } - $currentPosition ++; + ++$currentPosition; if ( $lookingForComma ) { continue; } - $quantity ++; + ++$quantity; $lookingForComma = true; } diff --git a/WPForms/Sniffs/Formatting/EmptyLineAfterAssigmentVariablesSniff.php b/WPForms/Sniffs/Formatting/EmptyLineAfterAssigmentVariablesSniff.php index 761093e..55de32a 100644 --- a/WPForms/Sniffs/Formatting/EmptyLineAfterAssigmentVariablesSniff.php +++ b/WPForms/Sniffs/Formatting/EmptyLineAfterAssigmentVariablesSniff.php @@ -111,7 +111,7 @@ private function getTokenNextLine( $phpcsFile, $semicolon ) { $nextLineTokens = []; $count = count( $tokens ); - for ( $i = $semicolon; $i < $count; $i ++ ) { + for ( $i = $semicolon; $i < $count; $i++ ) { if ( $tokens[ $i ]['line'] > $nextLine ) { break; } diff --git a/WPForms/Sniffs/Formatting/SwitchSniff.php b/WPForms/Sniffs/Formatting/SwitchSniff.php index 64aa256..00457bc 100644 --- a/WPForms/Sniffs/Formatting/SwitchSniff.php +++ b/WPForms/Sniffs/Formatting/SwitchSniff.php @@ -182,13 +182,15 @@ private function lineDistance( File $phpcsFile, $endPtr, $startPtr ) { ], true ) || - ( $tokens[ $ptr ]['code'] === T_COMMENT && - $phpcsFile->findFirstOnLine( [ T_WHITESPACE, T_COMMENT ], $ptr, true ) === false ) + ( + $tokens[ $ptr ]['code'] === T_COMMENT && + $phpcsFile->findFirstOnLine( [ T_WHITESPACE, T_COMMENT ], $ptr, true ) === false + ) ) { $commentLines[] = $tokens[ $ptr ]['line']; } - $ptr ++; + ++$ptr; } return max( diff --git a/WPForms/Sniffs/PHP/BackSlashSniff.php b/WPForms/Sniffs/PHP/BackSlashSniff.php index e031180..3b9af81 100644 --- a/WPForms/Sniffs/PHP/BackSlashSniff.php +++ b/WPForms/Sniffs/PHP/BackSlashSniff.php @@ -77,7 +77,7 @@ private function processCode( $phpcsFile, $stackPtr ) { return; } - $startPtr ++; + ++$startPtr; if ( $tokens[ $startPtr ]['code'] !== T_NS_SEPARATOR ) { return; diff --git a/WPForms/Tests/TestCase.php b/WPForms/Tests/TestCase.php index 3124dcc..ed0859c 100644 --- a/WPForms/Tests/TestCase.php +++ b/WPForms/Tests/TestCase.php @@ -56,6 +56,7 @@ protected function process( Sniff $className, $rulesetName = '' ) { throw new RuntimeException( sprintf( 'The %s file does not exist', + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $localFile ) ); diff --git a/WPForms/Tests/Tests/BaseSniffTest.php b/WPForms/Tests/Tests/BaseSniffTest.php index c3546af..8ebebc1 100644 --- a/WPForms/Tests/Tests/BaseSniffTest.php +++ b/WPForms/Tests/Tests/BaseSniffTest.php @@ -74,6 +74,7 @@ public function testGetRelativePath() { $classFileName = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'PHP_CodeSniffertemp_folder0000' . DIRECTORY_SEPARATOR . $relativePath; if ( file_exists( $classFileName ) ) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.unlink_unlink unlink( $classFileName ); } @@ -110,8 +111,10 @@ private function mkdirRecursive( $path ) { } if ( $dir !== '' && ! is_dir( $dir ) && strpos( $dir, '.' ) === false ) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir mkdir( $dir ); } elseif ( ! file_exists( $dir ) && strpos( $dir, '.' ) !== false ) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_touch touch( $dir ); } }