diff --git a/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php b/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php index 568d116f0..20a5daae5 100644 --- a/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php +++ b/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php @@ -656,7 +656,8 @@ private function isPartOfStatementAndWithIncrementOrDecrementOperator(File $phpc [T_STRING_CONCAT, T_ECHO, T_RETURN, T_EXIT, T_PRINT, T_COMMA, T_EMPTY, T_EVAL, T_YIELD], Tokens::$operators, Tokens::$assignmentTokens, - Tokens::$booleanOperators + Tokens::$booleanOperators, + Tokens::$castTokens ), true ); diff --git a/tests/Sniffs/Variables/data/unusedVariableErrors.php b/tests/Sniffs/Variables/data/unusedVariableErrors.php index 2f0c25768..41ce0e13c 100644 --- a/tests/Sniffs/Variables/data/unusedVariableErrors.php +++ b/tests/Sniffs/Variables/data/unusedVariableErrors.php @@ -128,3 +128,7 @@ function ($b) { --$a; return $b; }; + +function ($s): string { + return (string) ++$s; +};