diff --git a/includes/class-admin.php b/includes/class-admin.php
index 6b1bf67..bfb924d 100644
--- a/includes/class-admin.php
+++ b/includes/class-admin.php
@@ -23,7 +23,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function dashboard_right_now() {
+ public static function dashboard_right_now(): void {
$total_files = wp_count_posts( 'scliveticker_tick' );
echo '
';
@@ -37,7 +37,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function register_settings_page() {
+ public static function register_settings_page(): void {
add_submenu_page(
'edit.php?post_type=scliveticker_tick',
'Liveticker ' . __( 'Settings', 'stklcode-liveticker' ),
@@ -56,7 +56,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function register_settings() {
+ public static function register_settings(): void {
register_setting(
'scliveticker_settings',
self::OPTION,
@@ -132,7 +132,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_general_section() {
+ public static function settings_general_section(): void {
}
/**
@@ -140,7 +140,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_uninstall_section() {
+ public static function settings_uninstall_section(): void {
}
/**
@@ -148,7 +148,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_enable_ajax_field() {
+ public static function settings_enable_ajax_field(): void {
$checked = self::$options['enable_ajax'];
echo ' ';
@@ -161,7 +161,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_poll_interval_field() {
+ public static function settings_poll_interval_field(): void {
$poll_interval = self::$options['poll_interval'];
echo ' ';
@@ -175,7 +175,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_enable_css_field() {
+ public static function settings_enable_css_field(): void {
$checked = self::$options['enable_css'];
echo ' ';
@@ -188,7 +188,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_show_feed_field() {
+ public static function settings_show_feed_field(): void {
$checked = self::$options['show_feed'];
echo ' ';
@@ -203,7 +203,7 @@ class Admin extends SCLiveticker {
*
* @since 1.2
*/
- public static function settings_enable_shortcode_field() {
+ public static function settings_enable_shortcode_field(): void {
$checked = self::$options['enable_shortcode'];
echo ' ';
@@ -218,7 +218,7 @@ class Admin extends SCLiveticker {
*
* @since 1.2
*/
- public static function settings_embedded_script_field() {
+ public static function settings_embedded_script_field(): void {
$checked = self::$options['embedded_script'];
echo ' ';
@@ -231,7 +231,7 @@ class Admin extends SCLiveticker {
*
* @return void
*/
- public static function settings_page() {
+ public static function settings_page(): void {
include SCLIVETICKER_DIR . 'views/settings-page.php';
}
@@ -242,7 +242,7 @@ class Admin extends SCLiveticker {
*
* @return array Parsed arguments.
*/
- public static function validate_settings( $input ) {
+ public static function validate_settings( array $input ): array {
$defaults = self::default_options();
$result['enable_ajax'] = isset( $input['enable_ajax'] ) ? intval( $input['enable_ajax'] ) : 0;
@@ -261,7 +261,7 @@ class Admin extends SCLiveticker {
* @return void
* @since 1.1
*/
- public static function register_block() {
+ public static function register_block(): void {
wp_register_script(
'scliveticker-editor',
SCLIVETICKER_BASE . 'scripts/block.min.js',
diff --git a/includes/class-api.php b/includes/class-api.php
index 0feb0d3..1a3f226 100644
--- a/includes/class-api.php
+++ b/includes/class-api.php
@@ -15,6 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
use DateTime;
+use WP_REST_Request;
/**
* Liveticker.
@@ -27,7 +28,7 @@ class Api {
*
* @return void
*/
- public static function init() {
+ public static function init(): void {
// Add rendered modification date to WP_Post object.
register_rest_field(
'scliveticker_tick',
@@ -47,12 +48,12 @@ class Api {
/**
* Filter tick queries by ticker slug and date.
*
- * @param array $args Query vars.
- * @param \WP_REST_Request $request The REST request.
+ * @param array $args Query vars.
+ * @param WP_REST_Request $request The REST request.
*
* @return array Filtered query values.
*/
- public static function tick_query_filter( $args, $request ) {
+ public static function tick_query_filter( array $args, WP_REST_Request $request ): array {
// Extract arguments.
$ticker_slug = $request->get_param( 'ticker' );
$limit = intval( $request->get_param( 'limit' ) );
diff --git a/includes/class-scliveticker.php b/includes/class-scliveticker.php
index 89ab174..c24dfaa 100644
--- a/includes/class-scliveticker.php
+++ b/includes/class-scliveticker.php
@@ -62,7 +62,7 @@ class SCLiveticker {
*
* @return void
*/
- public static function init() {
+ public static function init(): void {
// Skip on autosave.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
@@ -114,7 +114,7 @@ class SCLiveticker {
*
* @return void
*/
- public static function register_types() {
+ public static function register_types(): void {
// Add new taxonomy, make it hierarchical (like categories).
$labels = array(
'name' => _x( 'Ticker', 'taxonomy general name', 'stklcode-liveticker' ),
@@ -182,7 +182,7 @@ class SCLiveticker {
*
* @return string
*/
- public static function shortcode_ticker_show( $atts ) {
+ public static function shortcode_ticker_show( array $atts ): string {
// Indicate presence of shortcode (to enqueue styles/scripts later).
self::$shortcode_present = true;
@@ -259,7 +259,7 @@ class SCLiveticker {
* @return void
* @since 1.1 Combined former methods "enqueue_styles" and "enqueue_scripts".
*/
- public static function enqueue_resources() {
+ public static function enqueue_resources(): void {
// Only add if shortcode is present.
if ( self::$shortcode_present || self::$widget_present || self::block_present() ) {
wp_enqueue_script(
@@ -301,7 +301,7 @@ class SCLiveticker {
*
* @return void
*/
- public static function ajax_update() {
+ public static function ajax_update(): void {
// Verify AJAX nonce.
check_ajax_referer( 'scliveticker_update-ticks' );
@@ -394,7 +394,7 @@ class SCLiveticker {
*
* @return void
*/
- public static function mark_widget_present() {
+ public static function mark_widget_present(): void {
self::$widget_present = true;
}
@@ -405,7 +405,7 @@ class SCLiveticker {
*
* @return void
*/
- protected static function update_options( $options = null ) {
+ protected static function update_options( ?array $options = null ): void {
self::$options = wp_parse_args(
get_option( self::OPTION ),
self::default_options()
@@ -417,7 +417,7 @@ class SCLiveticker {
*
* @return array The options array.
*/
- protected static function default_options() {
+ protected static function default_options(): array {
return array(
'enable_ajax' => 1,
'poll_interval' => 60,
@@ -439,7 +439,7 @@ class SCLiveticker {
*
* @return string HTML code of tick.
*/
- private static function tick_html( $time, $title, $content, $id ) {
+ private static function tick_html( string $time, string $title, string $content, int $id ): string {
if ( self::$options['enable_shortcode'] ) {
$content = do_shortcode( $content );
}
@@ -460,7 +460,7 @@ class SCLiveticker {
*
* @return string HTML code of widget tick.
*/
- public static function tick_html_widget( $time, $title, $highlight, $id = 0 ) {
+ public static function tick_html_widget( string $time, string $title, bool $highlight, int $id = 0 ): string {
$out = ' 'scliveticker_tick' ) );
foreach ( $ticks->get_posts() as $tick ) {
diff --git a/includes/class-widget.php b/includes/class-widget.php
index 1a1c65c..d738fcf 100644
--- a/includes/class-widget.php
+++ b/includes/class-widget.php
@@ -31,7 +31,7 @@ class Widget extends WP_Widget {
/**
* Register the widget.
*/
- public static function register() {
+ public static function register(): void {
register_widget( __CLASS__ );
}
@@ -164,7 +164,7 @@ class Widget extends WP_Widget {
*
* @return array Complete instance configuration.
*/
- private static function fill_options_with_defaults( $instance ) {
+ private static function fill_options_with_defaults( array $instance ): array {
$default = array(
'title' => '',
'category' => '',
diff --git a/stklcode-liveticker.php b/stklcode-liveticker.php
index 9a775a9..c59615f 100644
--- a/stklcode-liveticker.php
+++ b/stklcode-liveticker.php
@@ -68,7 +68,7 @@ spl_autoload_register( 'scliveticker_autoload' );
*
* @return void
*/
-function scliveticker_autoload( $class_name ) {
+function scliveticker_autoload( string $class_name ): void {
$plugin_classes = array(
'SCLiveticker\\SCLiveticker',
'SCLiveticker\\Admin',
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 482f425..ede8667 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -28,7 +28,7 @@ require_once "{$_tests_dir}/includes/functions.php";
/**
* Manually load the plugin being tested.
*/
-function _manually_load_plugin() {
+function _manually_load_plugin(): void {
require dirname( dirname( __FILE__ ) ) . '/stklcode-liveticker.php';
}
diff --git a/tests/test-api.php b/tests/test-api.php
index 0ee8ea8..f78f0cb 100644
--- a/tests/test-api.php
+++ b/tests/test-api.php
@@ -24,7 +24,7 @@ class Test_API extends WP_UnitTestCase {
*
* @return void
*/
- public function set_up() {
+ public function set_up(): void {
parent::set_up();
global $wp_rest_server;
$wp_rest_server = new WP_REST_Server();
@@ -36,7 +36,7 @@ class Test_API extends WP_UnitTestCase {
*
* @return void
*/
- public function test_register_route() {
+ public function test_register_route(): void {
global $wp_rest_server;
$routes = $wp_rest_server->get_routes();
@@ -52,7 +52,7 @@ class Test_API extends WP_UnitTestCase {
*
* @return void
*/
- public function test_get_ticks() {
+ public function test_get_ticks(): void {
global $wp_rest_server;
$request = new WP_REST_Request( 'GET', '/wp/v2/scliveticker_tick' );