WordPress\AiClientDependencies\Http\Discovery

ClassDiscovery::safeClassExists │ public static │ WP 1.0

We need a "safe" version of PHP's "class_exists" because Magento has a bug (or they call it a "feature"). Magento is throwing an exception if you do class_exists() on a class that ends with "Factory" and if that file does not exits.

This function catches all potential exceptions and makes sure to always return a boolean.

Метод класса: ClassDiscovery{}

Хуков нет.

Возвращает

bool.

Использование

$result = ClassDiscovery::safeClassExists( $class );
$class(строка) (обязательный)
.

Код ClassDiscovery::safeClassExists() WP 7.1.4

public static function safeClassExists($class)
{
    try {
        return class_exists($class) || interface_exists($class);
    } catch (\Exception $e) {
        return \false;
    }
}