From 473a17de3cfecef281aef0d69e0204fe73b7a630 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Nov 2024 19:05:44 +0100 Subject: [PATCH] CS/QA: various minor tweaks --- Yoast/Sniffs/Commenting/CoversTagSniff.php | 2 +- Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php | 4 ++-- Yoast/Sniffs/Files/FileNameSniff.php | 2 +- Yoast/Sniffs/Files/TestDoublesSniff.php | 2 +- Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php | 1 + Yoast/Sniffs/Yoast/JsonEncodeAlternativeSniff.php | 10 +++++----- phpunit-bootstrap.php | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Yoast/Sniffs/Commenting/CoversTagSniff.php b/Yoast/Sniffs/Commenting/CoversTagSniff.php index 5f6e8bc3..ccdf9872 100644 --- a/Yoast/Sniffs/Commenting/CoversTagSniff.php +++ b/Yoast/Sniffs/Commenting/CoversTagSniff.php @@ -267,7 +267,7 @@ public function process( File $phpcsFile, $stackPtr ) { continue; } - if ( ! isset( $first ) ) { + if ( $first === null ) { $first = \explode( '-', $ptrs ); $data = [ $tokens[ $first[0] ]['line'] ]; continue; diff --git a/Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php b/Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php index 8355a5d7..73da6eed 100644 --- a/Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php +++ b/Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php @@ -35,7 +35,7 @@ public function register() { * @param File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the stack passed in $tokens. * - * @return void|int Optionally returns a stack pointer. This sniff will not be + * @return int|void Optionally returns a stack pointer. This sniff will not be * called again on the current file until the returned stack * pointer is reached. */ @@ -57,7 +57,7 @@ public function process( File $phpcsFile, $stackPtr ) { * @param File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the stack passed in $tokens. * - * @return void|int If covers annotations were found (or this is not a test class), + * @return int|void If covers annotations were found (or this is not a test class), * will return the stack pointer to the end of the class. */ private function process_class( File $phpcsFile, $stackPtr ) { diff --git a/Yoast/Sniffs/Files/FileNameSniff.php b/Yoast/Sniffs/Files/FileNameSniff.php index bfb6a8ae..7e581704 100644 --- a/Yoast/Sniffs/Files/FileNameSniff.php +++ b/Yoast/Sniffs/Files/FileNameSniff.php @@ -203,7 +203,7 @@ public function process( File $phpcsFile, $stackPtr ) { $oo_name = ObjectDeclarations::getName( $phpcsFile, $oo_structure ); - if ( ! empty( $oo_name ) ) { + if ( \is_string( $oo_name ) && $oo_name !== '' ) { if ( $this->is_in_psr4_path( $phpcsFile, $file ) ) { $error = 'Directory marked as a PSR-4 path. File names should 100%% match the name of the OO structure contained in the file for PSR-4 compliance.'; diff --git a/Yoast/Sniffs/Files/TestDoublesSniff.php b/Yoast/Sniffs/Files/TestDoublesSniff.php index 58def16f..d892448f 100644 --- a/Yoast/Sniffs/Files/TestDoublesSniff.php +++ b/Yoast/Sniffs/Files/TestDoublesSniff.php @@ -63,7 +63,7 @@ public function register() { * @param File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the stack passed in $tokens. * - * @return void|int Void or $stackPtr to the end of the file if no basepath was set + * @return int|void Void or $stackPtr to the end of the file if no basepath was set * or no valid doubles_path(s) were found. */ public function process( File $phpcsFile, $stackPtr ) { diff --git a/Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php b/Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php index 1033458e..12b7d2be 100644 --- a/Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -178,6 +178,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * @param string $regex The punctuation regular expression to use. * @param string $transform_type Whether to do a partial or complete transform. * Valid values are: 'full', 'case', 'punctuation'. + * * @return string */ protected function transform( $text_string, $regex, $transform_type = 'full' ) { diff --git a/Yoast/Sniffs/Yoast/JsonEncodeAlternativeSniff.php b/Yoast/Sniffs/Yoast/JsonEncodeAlternativeSniff.php index 05aa48fe..819d237e 100644 --- a/Yoast/Sniffs/Yoast/JsonEncodeAlternativeSniff.php +++ b/Yoast/Sniffs/Yoast/JsonEncodeAlternativeSniff.php @@ -29,10 +29,10 @@ final class JsonEncodeAlternativeSniff extends AbstractFunctionRestrictionsSniff * * @since 3.0.0 * - * @var array Function names as the keys and the name of the first declared parameter - * as the value. - * There can be multiple parameter names if the parameter - * was renamed over time. + * @var array> Function names as the keys and the name of the first declared parameter + * as the value. + * There can be multiple parameter names if the parameter + * was renamed over time. */ private const PARAM_INFO = [ 'json_encode' => 'value', @@ -47,7 +47,7 @@ final class JsonEncodeAlternativeSniff extends AbstractFunctionRestrictionsSniff /** * Groups of functions to restrict. * - * @return array> + * @return array>> */ public function getGroups() { return [ diff --git a/phpunit-bootstrap.php b/phpunit-bootstrap.php index 50bc6a59..7b1538c4 100644 --- a/phpunit-bootstrap.php +++ b/phpunit-bootstrap.php @@ -53,7 +53,7 @@ for that PHPCS install. '; - die( 1 ); + exit( 1 ); } /*