Skip to content

get_class() TypeError in Deprecated/Hook.php:77 on PHP 8+ #444

@therealgilles

Description

@therealgilles

Description:

In AC\Deprecated\Hook::get_callbacks(), line 77 calls get_class($function[0]) when processing array-style callbacks. However, $function[0] can be a string (class name) when a callback is registered as a static method array (['ClassName', 'methodName']). In PHP 8+, get_class() requires an object argument, causing:

Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given

Suggested fix (line 77 of classes/Deprecated/Hook.php):

$class_name = is_object($function[0]) ? get_class($function[0]) : $function[0];
$messages[] = sprintf('%s::%s()', $class_name, $function[1]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions