public static function validateObjectResource($object, $requireClass, $i, $allowForm = true): void
    {
        if ($allowForm && $object instanceof FormInterface) {
            $object = $object->getData();
        }

        if (!\is_object($object) || !$object instanceof $requireClass) {
            throw new UnexpectedTypeException($object, $requireClass, $i);
        }
    }