public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (null === $value) { return null; } if (!is_array($value)) { throw ConversionException::conversionFailed($value, $this->getName()); } return Coder::encode($value); }
public function testMemoryUsage() { $var = ['a' => 'b', 'c' => null, 'd' => 'e"e', 'f' => str_repeat('0', 1024)]; // allocate zval's $before = 0; $after = 0; $real_before = 0; $real_after = 0; $before = memory_get_usage(); $real_before = memory_get_usage(true); for ($i = 0; $i < 10000; $i++) { Coder::decode(Coder::encode($var)); } unset($i); gc_collect_cycles(); $after = memory_get_usage(); $real_after = memory_get_usage(true); if ($after > $before) { $this->fail(sprintf("Memory is corrupted (%d bytes not cleared)", $after - $before)); } if ($real_after > $real_before) { $this->fail(sprintf("Real memory is corrupted (%d bytes not cleared)", $real_after - $real_before)); } }
public static function addArray($label, $value) { self::$tests[$label] = [$value, Coder::encode($value)]; }