<?php

namespace DiDom;

class Errors
{
    /**
     * @var bool
     */
    protected static $internalErrors;

    /**
     * @var bool
     */
    protected static $disableEntities;

    /**
     * Disable error reporting.
     */
    public static function disable()
    {
        self::$internalErrors = libxml_use_internal_errors(true);
        self::$disableEntities = libxml_disable_entity_loader(true);
    }

    /**
     * Restore error reporting.
     * 
     * @param bool $clear
     */
    public static function restore($clear = true)
    {
        if ($clear) {
            libxml_clear_errors();
        }

        libxml_use_internal_errors(self::$internalErrors);
        libxml_disable_entity_loader(self::$disableEntities);
    }
}

<?php

namespace DiDom;

class Errors
{
    /**
     * @var bool
     */
    protected static $internalErrors;

    /**
     * @var bool
     */
    protected static $disableEntities;

    /**
     * Disable error reporting.
     */
    public static function disable()
    {
        self::$internalErrors = libxml_use_internal_errors(true);

        if (\LIBXML_VERSION < 20900) {
            self::$disableEntities = libxml_disable_entity_loader(true);
        }
    }

    /**
     * Restore error reporting.
     * 
     * @param bool $clear
     */
    public static function restore($clear = true)
    {
        if ($clear) {
            libxml_clear_errors();
        }

        libxml_use_internal_errors(self::$internalErrors);

        if (\LIBXML_VERSION < 20900) {
            libxml_disable_entity_loader(self::$disableEntities);
        }
    }
}

Fix deprecation notice in PHP 8 for libxml_disable_entity_loader
Fix deprecation notice in PHP 8 for libxml_disable_entity_loader

PHP 8 [deprecates `libxml_disable_entity_loader`](https://php.watch/versions/8.0/libxml_disable_entity_loader-deprecation) function, and this fixes the deprecation notice by not calling the function on libxml 2.9, where external entity loader is disabled by default and is not necessary to explicitly disable it.
