From 61ba951f0b15a4d9ed63c4b40863e699fc9c3cc1 Mon Sep 17 00:00:00 2001
From: Stefan Kalscheuer <stefan@stklcode.de>
Date: Thu, 9 Nov 2023 18:14:31 +0100
Subject: [PATCH] update code style to WPCS v3.0

---
 .github/workflows/test.yml | 2 +-
 composer.json              | 6 +++---
 includes/class-widget.php  | 5 +++--
 stklcode-liveticker.php    | 8 ++++----
 views/widget-form.php      | 2 +-
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 17d6a82..bf25ccc 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -39,7 +39,7 @@ jobs:
       - name: Setup PHP
         uses: shivammathur/setup-php@v2
         with:
-          php-version: '8.0'
+          php-version: '8.2'
           tools: composer
       - name: Setup Node
         uses: actions/setup-node@v3
diff --git a/composer.json b/composer.json
index b3f9e65..8dbe40c 100644
--- a/composer.json
+++ b/composer.json
@@ -21,14 +21,14 @@
     "composer/installers": "~1.12"
   },
   "require-dev": {
-    "dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
+    "dealerdirect/phpcodesniffer-composer-installer": "^v1.0",
     "matthiasmullie/minify": "^1.3",
     "phpcompatibility/phpcompatibility-wp": "^2.1",
     "phpunit/phpunit": "^5|^6|^7|^8|^9",
     "slowprog/composer-copy-file": "~0.3",
     "squizlabs/php_codesniffer": "^3.7",
-    "wp-coding-standards/wpcs": "^2.3",
-    "yoast/phpunit-polyfills": "^1.0"
+    "wp-coding-standards/wpcs": "^3.0",
+    "yoast/phpunit-polyfills": "^2.0"
   },
   "scripts": {
     "post-install-cmd": [
diff --git a/includes/class-widget.php b/includes/class-widget.php
index 1996ff0..11c51bb 100644
--- a/includes/class-widget.php
+++ b/includes/class-widget.php
@@ -95,15 +95,16 @@ class Widget extends WP_Widget {
 
 		$wp_query = new WP_Query( $args );
 		$cnt      = 0;
-		while ( $wp_query->have_posts() && ( $count <= 0 || ++ $cnt < $count ) ) {
+		while ( $wp_query->have_posts() && ( $count <= 0 || ++$cnt < $count ) ) {
 			$wp_query->the_post();
-			// @codingStandardsIgnoreLine
+			// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
 			echo SCLiveticker::tick_html_widget(
 				esc_html( get_the_time( 'd.m.Y - H:i' ) ),
 				get_the_title(),
 				( '1' === $highlight && get_the_time( 'U' ) > ( time() - $highlight_time ) ),
 				get_the_ID()
 			);
+			// phpcs:enable
 		}
 
 		echo '</ul>';
diff --git a/stklcode-liveticker.php b/stklcode-liveticker.php
index d4ac11b..353f55b 100644
--- a/stklcode-liveticker.php
+++ b/stklcode-liveticker.php
@@ -64,11 +64,11 @@ spl_autoload_register( 'scliveticker_autoload' );
 /**
  * Autoloader for Liveticker classes.
  *
- * @param string $class  Name of the class to load.
+ * @param string $class_name  Name of the class to load.
  *
  * @return void
  */
-function scliveticker_autoload( $class ) {
+function scliveticker_autoload( $class_name ) {
 	$plugin_classes = array(
 		'SCLiveticker\\SCLiveticker',
 		'SCLiveticker\\Admin',
@@ -76,11 +76,11 @@ function scliveticker_autoload( $class ) {
 		'SCLiveticker\\System',
 		'SCLiveticker\\Widget',
 	);
-	if ( in_array( $class, $plugin_classes, true ) ) {
+	if ( in_array( $class_name, $plugin_classes, true ) ) {
 		require_once sprintf(
 			'%s/includes/class-%s.php',
 			SCLIVETICKER_DIR,
-			strtolower( str_replace( '_', '-', substr( $class, 13 ) ) )
+			strtolower( str_replace( '_', '-', substr( $class_name, 13 ) ) )
 		);
 	}
 }
diff --git a/views/widget-form.php b/views/widget-form.php
index 7e986ff..63ef13e 100644
--- a/views/widget-form.php
+++ b/views/widget-form.php
@@ -54,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) {
 					<?php esc_html_e( 'all', 'stklcode-liveticker' ); ?>
 				</option>
 				<?php
-				for ( $i = 1; $i <= 10; $i ++ ) {
+				for ( $i = 1; $i <= 10; $i++ ) {
 					printf(
 						'<option value="%d"%s>%d</option>',
 						$i,