How to solve error on php 7.2?

: sizeof(): Parameter must be an array or an object that implements Countable in
public function notices() {

 if ( isset( $_GET['invalidkeyerror'] ) && '1' == $_GET['invalidkeyerror'] ) {
 appthemes_display_notice( 'error', __( 'Sorry, that key does not appear to be valid. Please try again.', APP_TD ) );
}

 if ( isset( $this->error ) && sizeof( $this->error ) > 0 && $this->error->get_error_code() ) { //here error
 $error_html = '<ul class="errors">';
 foreach ( $this->error->errors as $error ) {
 $error_html .= '<li>' . $error[0] . '</li>';
}
 $error_html .= '</ul>';
 appthemes_display_notice( 'error', $error_html );
}
 }
March 19th 20 at 08:32
3 answers
March 19th 20 at 08:34
Solution
... && !empty($this->error) && count($this->error) ...

or just
... && is_object($this->error) ...

the root of the problem is that sizeof cannot accept a string or empty value
if ( isset( $this->error ) && sizeof( $this->error ) > 0 && $this->error->get_error_code() ) {
replaced
if ( isset( $this->error ) && ! empty($error) > 0 && $this->error->get_error_code() ) {

PHP error was gone, but the error warning is gone... - Aniyah_Doyle8 commented on March 19th 20 at 08:37
or just
... && is_object($this->error) ...
It is suitable work, the review gave almost the same answer
isset( $this->error ) && is_object($this->error) && $this->error->get_error_code()

I left this:
isset( $this->error ) && is_object($this->error) > 0 && $this->error->get_error_code()
Or zero it is better to remove? - Aniyah_Doyle8 commented on March 19th 20 at 08:40
@Aniyah_Doyle8, of course clean.
is_object returns true|false - Annabelle49 commented on March 19th 20 at 08:43
March 19th 20 at 08:36
Solution
isset( $this->error ) && is_object($this->error) && $this->error->get_error_code()
March 19th 20 at 08:38
if $this->error string, \mb_strlen($this->error) > 0

Find more questions by tags PHP