Exemple #1
0
 /** {@inheritdoc} */
 public function convertToPHPValue($value)
 {
     if (is_object($value)) {
         throw ConversionException::conversionFailed(gettype($value), $this);
     }
     return null === $value ? null : (int) $value;
 }
Exemple #2
0
 /** {@inheritdoc} */
 public function convertToPHPValue($value)
 {
     if (null === $value || $value instanceof \DateTime) {
         return $value;
     }
     $val = date_create($value);
     if (!$val) {
         throw ConversionException::conversionFailed($value, $this);
     }
     return $val;
 }
Exemple #3
0
 /** {@inheritdoc} */
 public function convertToPHPValue($value)
 {
     if (null === $value || is_array($value)) {
         return $value;
     }
     if (is_resource($value)) {
         $value = stream_get_contents($value);
     }
     $val = @unserialize($value);
     if (false === $val && 'b:0;' !== $value) {
         throw ConversionException::conversionFailed($value, $this);
     }
     return $val;
 }
Exemple #4
0
 /** {@inheritdoc} */
 public function convertToPHPValue($value)
 {
     if (null === $value) {
         return null;
     }
     if (is_string($value)) {
         $stream = fopen('php://memory', 'r+b');
         fwrite($stream, $value);
         rewind($stream);
         $value = $stream;
     }
     if (!is_resource($value)) {
         throw ConversionException::conversionFailed($value, $this);
     }
     return $value;
 }
Exemple #5
0
 /** {@inheritdoc} */
 public function convertToPHPValue($value)
 {
     if (null === $value) {
         return null;
     } elseif (is_string($value) && class_exists($value, false)) {
         return (new \ReflectionClass($value))->newInstanceWithoutConstructor();
     }
     if (is_resource($value)) {
         $value = stream_get_contents($value);
     }
     $val = @unserialize($value);
     if (false === $val && 'b:0;' !== $value) {
         throw ConversionException::conversionFailed($value, $this);
     }
     return $val;
 }