must be a valid class name, %s given

Description

get_parent_class() expects an argument, which must be either an object, or a valid class name. The object’s class name will be used; for the valid class name, it is recommended to use the ::class operator on the class name, and also, to check if the class exists first.

Example

<?php

$a = 1;
get_parent_class($a);

?>

Literal Examples

  • must be a valid class name, null given

  • must be a valid class name, integer given

Solutions

  • Check that the parameter is an object.

  • Make the string a valid class name, with the ::class operator.

  • Check if the string is an existing class, with a call to class_exists().