wordpress - PHP Notice: Object of class MyClass could not be converted to int

one text

PHP Notice: Object of class MyCourse could not be converted to int in /home/usr/public_html/wp-includes/post-template.php on line 310

post-template.php line 310:

    if ( $elements['page'] > count( $elements['pages'] ) ) { // if the requested page doesn't exist
        $elements['page'] = count( $elements['pages'] ); // give them the highest numbered page that DOES exist
    }

Class call within register_shortcodes():

if ( $has_course ) { // if a quiz is supposed to be rendered with the course
                $entity = new MyCourse( array( 'id' => $post->post_parent ) );
                $presenter = $entity->get_presenter();
            }

Encountered this issue: while troubleshooting H5P shortcodes within legacy codebase.

Question: Is count() the culprit throwing this error?

Source