File "ObjectType.php"

Full Path: /home/warrior1/public_html/plugins/mailpoet/vendor-prefixed/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php
File size: 1.15 KB
MIME-type: text/x-php
Charset: utf-8

<?php
namespace MailPoetVendor\Doctrine\DBAL\Types;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform;
use function is_resource;
use function restore_error_handler;
use function serialize;
use function set_error_handler;
use function stream_get_contents;
use function unserialize;
class ObjectType extends Type
{
 public function getSQLDeclaration(array $column, AbstractPlatform $platform)
 {
 return $platform->getClobTypeDeclarationSQL($column);
 }
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
 return serialize($value);
 }
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
 if ($value === null) {
 return null;
 }
 $value = is_resource($value) ? stream_get_contents($value) : $value;
 set_error_handler(function (int $code, string $message) : bool {
 throw ConversionException::conversionFailedUnserialization($this->getName(), $message);
 });
 try {
 return unserialize($value);
 } finally {
 restore_error_handler();
 }
 }
 public function getName()
 {
 return Types::OBJECT;
 }
 public function requiresSQLCommentHint(AbstractPlatform $platform)
 {
 return \true;
 }
}