enter image description hereI use PHP 8.2.0. Kallyas wordpress theme.

When clicking on the link http://***/wp-admin/widgets.php or reloading the page, an error occurs in the footer:

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in C:\wamp64\www***\wp-content\themes\kallyas\template_helpers\tweeter-helper.php on line 178

    $cached_tweets = array();
**178 line! ->>>**  for ( $i = 0; $i <= count( $tweets ); $i ++ ) {
                if( is_object( $tweets ) || ! isset( $tweets[ $i ] ) ) {
                    continue;
                }
                if ( ! empty( $tweets[ $i ] ) ) {
                    $cached_tweets[ $i ]['created_at'] = $tweets[ $i ]->created_at;
                    $cached_tweets[ $i ]['text']       = $tweets[ $i ]->text;
                    $cached_tweets[ $i ]['status_id']  = $tweets[ $i ]->id_str;
                }
            }

            $cache_time = 60 * 60 * intval($args['cachetime']);
            set_transient('znhg_twitter_'. $args['username'], $cached_tweets, $cache_time );

        }

        return $cached_tweets;

    }
}

I can't figure out how to solve this problem

UPD:

If count( $tweets ) replace like this:

count (( array ) $value)

The ERROR is dissapear!

0

There are 0 answers