Skip to content

Commit

Permalink
Fix phpcs locally with PHP 8.2, fix #43
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design authored Feb 8, 2024
1 parent 67bd517 commit 45cd985
Show file tree
Hide file tree
Showing 36 changed files with 67 additions and 64 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file and formatte
## [1.1.1] - 2024-XX-XX
### Fixed
- Function return type broke WPForms.Formatting.EmptyLineBeforeReturn sniff.
- The phpcs did not work locally with PHP 8+.

## [1.1.0] - 2023-09-07
### Fixed
Expand Down
10 changes: 5 additions & 5 deletions WPForms/Sniffs/BaseSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function getRootDirectory( $phpcsFile ) {
}

/**
* Get relative path from project root directory.
* Get a relative path from project root directory.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function normalizeFilename( $filename ) {
}

/**
* Get first argument of a function.
* Get the first argument of a function.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -152,7 +152,7 @@ protected function getFirstArgument( $phpcsFile, $stackPtr ) {
}

/**
* Check whether the token is break in switch statement.
* Check whether the token is break in the switch statement.
*
* @since 1.0.4
*
Expand All @@ -176,7 +176,7 @@ protected function isBreakInSwitch( $phpcsFile, $token ) {
}

/**
* Get fully qualified class name.
* Get a fully qualified class name.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -219,7 +219,7 @@ protected function getFullyQualifiedClassName( $phpcsFile ) {
$fqcn = $this->camelToSnake( str_replace( '\\', '', $namespace ) ) . '_' . $class;

// Fix WPForms.
// Remove _plugin for main plugin class, which is usually Plugin.
// Remove _plugin for the main plugin class, which is usually Plugin.
$fqcn = str_replace( [ 'wp_forms', '_plugin' ], [ 'wpforms', '' ], $fqcn );

$fqcnArr = explode( '_', $fqcn );
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/DeprecatedTagHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/DeprecatedTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DescriptionStopSymbolPropertySniff extends PropertyBaseSniff {
use Description;

/**
* Called to process class member vars.
* Process Process this test when one of its tokens is encountered..
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/DescriptionStopSymbolSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/LanguageInjectionSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
4 changes: 2 additions & 2 deletions WPForms/Sniffs/Comments/NoSpacesAfterParamTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand All @@ -59,7 +59,7 @@ public function process( File $phpcsFile, $stackPtr ) {
return;
}

// More than 1 spaces.
// More than one space.
if ( $tokens[ $tag['tag'] + 1 ]['length'] > 1 ) {
$phpcsFile->addError(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/PHPDocDefineSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/PHPDocHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
3 changes: 2 additions & 1 deletion WPForms/Sniffs/Comments/ParamTagHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
* @param File $phpcsFile The PHP_CodeSniffer file where the token was found.
* @param int $stackPtr The position in the PHP_CodeSniffer file's token stack where the token was found.
*
* @return void
* @noinspection UnusedFunctionResultInspection
*/
public function process( File $phpcsFile, $stackPtr ) {

Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/ReturnTagHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/ShortDescriptionHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/SinceTagDefineSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/SinceTagHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/SinceTagPropertySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SinceTagPropertySniff extends PropertyBaseSniff {
use CommentTag;

/**
* Called to process class member vars.
* Process class member vars.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/SinceTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Comments/TranslatorsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand All @@ -46,7 +46,7 @@ public function process( File $phpcsFile, $stackPtr ) {
return;
}

// Detect the last ";" for detect end of this operation for multiline expressions.
// Detect the last ";" for detect the end of this operation for multiline expressions.
$semicolon = $phpcsFile->findNext( [ T_SEMICOLON ], $stackPtr + 1 );
$nextAfterSemicolon = $phpcsFile->findNext( Tokens::$emptyTokens, $semicolon + 1, null, true );

Expand All @@ -57,7 +57,7 @@ public function process( File $phpcsFile, $stackPtr ) {

$nextLineTokens = $this->getTokenNextLine( $phpcsFile, $semicolon );

// If next line is empty line.
// If the next line is an empty line.
if ( empty( $nextLineTokens ) ) {
return;
}
Expand All @@ -77,7 +77,7 @@ public function process( File $phpcsFile, $stackPtr ) {
}

/**
* Get list of tokens that allowed in next line after assigment.
* Get the list of tokens that allowed in the next line after assigment.
*
* @since 1.0.0
*
Expand All @@ -95,7 +95,7 @@ private function getAllowedTokensAfterAssigment() {
}

/**
* Get tokens in last line.
* Get tokens in the last line.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -127,7 +127,7 @@ private function getTokenNextLine( $phpcsFile, $semicolon ) {
break;
}

// Skip if the next line is also assignment statement.
// Skip if the next line is also an assignment statement.
if ( in_array( $tokens[ $i ]['code'], Tokens::$assignmentTokens, true ) ) {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Formatting/EmptyLineBeforeReturnSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/Formatting/SwitchSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
4 changes: 2 additions & 2 deletions WPForms/Sniffs/PHP/BackSlashSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -123,7 +123,7 @@ private function processComments( $phpcsFile, $stackPtr ) {
}

/**
* Remove backslash message.
* Remove the backslash message.
*
* @since 1.0.0
*
Expand Down
2 changes: 1 addition & 1 deletion WPForms/Sniffs/PHP/ConditionsYodaDisableSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down
6 changes: 2 additions & 4 deletions WPForms/Sniffs/PHP/HooksMethodSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand All @@ -64,9 +64,7 @@ public function process( File $phpcsFile, $stackPtr ) {
return;
}

$classname = $this->getFullyQualifiedClassName( $phpcsFile );

if ( ! $classname ) {
if ( ! $this->getFullyQualifiedClassName( $phpcsFile ) ) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions WPForms/Sniffs/PHP/UseStatementSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function register() {
}

/**
* Processes this test, when one of its tokens is encountered.
* Process this test when one of its tokens is encountered.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -171,7 +171,7 @@ private function findInThrows( $phpcsFile, $entityName, $stackPtr ) {
$closePtr = $phpcsFile->findNext( T_DOC_COMMENT_CLOSE_TAG, $stackPtr + 1 );
$commentPtr = $phpcsFile->findNext( T_DOC_COMMENT_STRING, $stackPtr + 1, $closePtr );

if ( $commentPtr && $entityName === explode( ' ', $tokens[ $commentPtr ]['content'] )[0] ) {
if ( $commentPtr && $entityName === explode( ' ', $tokens[ $commentPtr ]['content'], 2 )[0] ) {
return true;
}
}
Expand Down
Loading

0 comments on commit 45cd985

Please sign in to comment.