/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = sqlite_fetch_array($this->handle, SQLITE_ASSOC))) { return FALSE; } foreach (array_keys($row) as $key) { if (NULL === $row[$key] || !isset($this->fields[$key])) { continue; } switch ($row[$key][0]) { case "": $row[$key] = Date::fromString(substr($row[$key], 1)); break; case "": $row[$key] = intval(substr($row[$key], 1)); break; case "": $row[$key] = floatval(substr($row[$key], 1)); break; } } if ($field) { return $row[$field]; } else { return $row; } }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = pg_fetch_assoc($this->handle))) { return FALSE; } foreach (array_keys($row) as $key) { switch ($this->fields[$key]) { case 'date': case 'time': case 'timestamp': $row[$key] = Date::fromString($row[$key], $this->tz); break; case 'bool': settype($row[$key], 'bool'); break; case 'int2': case 'int4': case 'int8': settype($row[$key], 'integer'); break; case 'float4': case 'float8': case 'numeric': settype($row[$key], 'double'); break; } } if ($field) { return $row[$field]; } else { return $row; } }
public function testSerialization() { $msg = new XPSoapMessage(); $msg->createCall('Test', 'testSerialization'); $this->assertEquals('Test', $msg->action); $this->assertEquals('testSerialization', $msg->method); $this->assertEquals('SOAP-ENV:Envelope', $msg->root()->getName()); $this->assertNotEmpty($msg->root()->getAttributes()); $msg->setData(array('int' => 1, 'float' => 6.1, 'string' => 'Binford', 'string2' => '"<&>"', 'bool' => TRUE, 'date' => Date::fromString('1977-12-14 11:55AM Europe/Berlin'), 'null' => NULL, 'array' => array(2, 3), 'hash' => array('class' => 'Test', 'method' => 'testSerialization'))); // Let's be somewhat forgiving on whitespace $src = trim(chop($msg->getSource(0))); $this->assertEquals('<SOAP-ENV:Envelope', substr($src, 0, 18)); $this->assertEquals('</SOAP-ENV:Envelope>', substr($src, -20)); $this->assertContains($src, '<int xsi:type="xsd:int">1</int>', 'integer'); $this->assertContains($src, '<float xsi:type="xsd:float">6.1</float>', 'float'); $this->assertContains($src, '<string xsi:type="xsd:string">Binford</string>', 'string'); $this->assertContains($src, '<string2 xsi:type="xsd:string">"<&>"</string2>', 'escaping'); $this->assertContains($src, '<bool xsi:type="xsd:boolean">true</bool>', 'bool'); $this->assertContains($src, '<date xsi:type="xsd:dateTime">1977-12-14T11:55:00+01:00</date>', 'date'); $this->assertContains($src, '<null xsi:nil="true"/>', 'null'); $this->assertContains($src, '<array xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">', 'array'); $this->assertContains($src, '<item xsi:type="xsd:int">2</item>', 'array.inner'); $this->assertContains($src, '<item xsi:type="xsd:int">3</item>', 'array.inner'); $this->assertContains($src, '<hash xsi:type="xsd:struct">', 'hash'); $this->assertContains($src, '<class xsi:type="xsd:string">Test</class>', 'hash.inner'); $this->assertContains($src, '<method xsi:type="xsd:string">testSerialization</method>', 'hash.inner'); return $src; }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!$this->handle instanceof SQLite3Result || FALSE === ($row = $this->handle->fetchArray(SQLITE3_ASSOC))) { return FALSE; } foreach ($row as $key => $value) { if (NULL === $value || !isset($this->fields[$key])) { continue; } switch ($value[0]) { case "": $row[$key] = Date::fromString(substr($value, 1)); break; case "": $row[$key] = intval(substr($value, 1)); break; case "": $row[$key] = floatval(substr($value, 1)); break; } } if ($field) { return $value; } else { return $row; } }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = mssql_fetch_assoc($this->handle))) { return FALSE; } foreach ($row as $key => $value) { if (NULL === $value || !isset($this->fields[$key])) { continue; } switch ($this->fields[$key]) { case 'datetime': $row[$key] = Date::fromString($value, $this->tz); break; case 'numeric': if (FALSE !== strpos($value, '.')) { settype($row[$key], 'double'); break; } // Fallthrough intentional case 'int': if ($value <= LONG_MAX && $value >= LONG_MIN) { settype($row[$key], 'integer'); } else { settype($row[$key], 'double'); } break; } } if ($field) { return $row[$field]; } else { return $row; } }
/** * Set up this test * */ public function setUp() { $this->tz = date_default_timezone_get(); date_default_timezone_set('GMT'); $this->nowTime = time(); $this->nowDate = new Date($this->nowTime); $this->refDate = Date::fromString('1977-12-14 11:55'); }
public function orderDateParamInfo() { $this->assertEquals(OCCURRENCE_OPTIONAL, $this->wrapper->getParamInfo('orderdate', PARAM_OCCURRENCE)); $this->assertEquals(Date::fromString('1977-12-14'), $this->wrapper->getParamInfo('orderdate', PARAM_DEFAULT)); $this->assertEquals(NULL, $this->wrapper->getParamInfo('orderdate', PARAM_PRECHECK)); $this->assertEquals(NULL, $this->wrapper->getParamInfo('orderdate', PARAM_POSTCHECK)); $this->assertEquals('core:string', $this->wrapper->getParamInfo('orderdate', PARAM_TYPE)); $this->assertEquals(array(), $this->wrapper->getParamInfo('orderdate', PARAM_VALUES)); $this->assertClass($this->wrapper->getParamInfo('orderdate', PARAM_CASTER), 'scriptlet.xml.workflow.casters.ToDate'); }
/** * Test instance creation from a string. * */ function test_from_string() { $date = Date::withYearMonthDay(2005, 8, 20); $this->assertTrue($date->isEqualTo(Date::fromString('2005-08-20'))); $this->assertTrue($date->isEqualTo(Date::fromString('2005-08-20T15:25:10'))); $this->assertTrue($date->isEqualTo(Date::fromString('20050820152510'))); $this->assertTrue($date->isEqualTo(Date::fromString('08/20/2005'))); $this->assertTrue($date->isEqualTo(Date::fromString('August 20, 2005'))); $this->assertTrue($date->isEqualTo(Date::fromString('20aug05'))); }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = sybase_fetch_assoc($this->handle))) { return FALSE; } foreach (array_keys($row) as $key) { if (NULL === $row[$key] || !isset($this->fields[$key])) { continue; } if ('datetime' === $this->fields[$key]) { $row[$key] = Date::fromString($row[$key], $this->tz); } } if ($field) { return $row[$field]; } else { return $row; } }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_object($this->handle) || NULL === ($row = mysqli_fetch_assoc($this->handle))) { return FALSE; } foreach (array_keys($row) as $key) { if (NULL === $row[$key] || !isset($this->fields[$key])) { continue; } switch ($this->fields[$key]) { case MYSQLI_TYPE_DATETIME: case MYSQLI_TYPE_DATE: case MYSQLI_TYPE_TIME: case MYSQLI_TYPE_TIMESTAMP: case MYSQLI_TYPE_NEWDATE: $row[$key] = '0000-00-00 00:00:00' === $row[$key] ? NULL : Date::fromString($row[$key], $this->tz); break; case MYSQLI_TYPE_LONGLONG: case MYSQLI_TYPE_LONG: case MYSQLI_TYPE_INT24: case MYSQLI_TYPE_SHORT: case MYSQLI_TYPE_TINY: case MYSQLI_TYPE_BIT: if ($row[$key] <= LONG_MAX && $row[$key] >= LONG_MIN) { settype($row[$key], 'integer'); } else { settype($row[$key], 'double'); } break; case MYSQLI_TYPE_FLOAT: case MYSQLI_TYPE_DOUBLE: case MYSQLI_TYPE_DECIMAL: case MYSQLI_TYPE_NEWDECIMAL: settype($row[$key], 'double'); break; } } if ($field) { return $row[$field]; } else { return $row; } }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = mysql_fetch_assoc($this->handle))) { return FALSE; } foreach (array_keys($row) as $key) { if (NULL === $row[$key] || !isset($this->fields[$key])) { continue; } switch ($this->fields[$key]) { case 'timestamp': if (strlen($row[$key]) == 14) { $time = sscanf((string) $row[$key], '%04s%02s%02s%02s%02s%02s'); $row[$key] = new Date(mktime($time[3], $time[4], $time[5], $time[1], $time[2], $time[0]), $this->tz); break; } case 'datetime': case 'date': $row[$key] = Date::fromString($row[$key], $this->tz); break; case 'int': if ($row[$key] <= LONG_MAX && $row[$key] >= LONG_MIN) { settype($row[$key], 'integer'); } else { settype($row[$key], 'double'); } break; case 'bit': settype($row[$key], 'integer'); break; case 'real': settype($row[$key], 'double'); break; } } if ($field) { return $row[$field]; } else { return $row; } }
public function convert($v, $type) { if ($v === null) { return $v; } switch ($type) { case "int": case "year": return intval($v); break; case "real": return floatval($v); break; case "datetime": case "date": return Date::fromString($v); break; default: return $v; break; } }
static function convert($v, $type) { if ($v === null) { return $v; } switch ($type) { case "bool": return (bool) $v; break; case "int": return intval($v); break; case "float": return floatval($v); break; case "date": return Date::fromString($v); break; default: return $v; break; } }
public function unserialize() { $_g = null; $p = $this->pos++; $_g = ord(substr($this->buf, $p, 1)); switch ($_g) { case 110: return null; break; case 116: return true; break; case 102: return false; break; case 122: return 0; break; case 105: return $this->readDigits(); break; case 100: $p1 = $this->pos; while (true) { $c = ord(substr($this->buf, $this->pos, 1)); if ($c >= 43 && $c < 58 || $c === 101 || $c === 69) { $this->pos++; } else { break; } unset($c); } return Std::parseFloat(_hx_substr($this->buf, $p1, $this->pos - $p1)); break; case 121: $len = $this->readDigits(); if (haxe_Unserializer_3($this, $_g, $len) !== 58 || $this->length - $this->pos < $len) { throw new HException("Invalid string length"); } $s = _hx_substr($this->buf, $this->pos, $len); $this->pos += $len; $s = urldecode($s); $this->scache->push($s); return $s; break; case 107: return Math::$NaN; break; case 109: return Math::$NEGATIVE_INFINITY; break; case 112: return Math::$POSITIVE_INFINITY; break; case 97: $buf = $this->buf; $a = new _hx_array(array()); $this->cache->push($a); while (true) { $c1 = ord(substr($this->buf, $this->pos, 1)); if ($c1 === 104) { $this->pos++; break; } if ($c1 === 117) { $this->pos++; $n = $this->readDigits(); $a[$a->length + $n - 1] = null; unset($n); } else { $a->push($this->unserialize()); } unset($c1); } return $a; break; case 111: $o = _hx_anonymous(array()); $this->cache->push($o); $this->unserializeObject($o); return $o; break; case 114: $n1 = $this->readDigits(); if ($n1 < 0 || $n1 >= $this->cache->length) { throw new HException("Invalid reference"); } return $this->cache[$n1]; break; case 82: $n2 = $this->readDigits(); if ($n2 < 0 || $n2 >= $this->scache->length) { throw new HException("Invalid string reference"); } return $this->scache[$n2]; break; case 120: throw new HException($this->unserialize()); break; case 99: $name = $this->unserialize(); $cl = $this->resolver->resolveClass($name); if ($cl === null) { throw new HException("Class not found " . _hx_string_or_null($name)); } $o1 = Type::createEmptyInstance($cl); $this->cache->push($o1); $this->unserializeObject($o1); return $o1; break; case 119: $name1 = $this->unserialize(); $edecl = $this->resolver->resolveEnum($name1); if ($edecl === null) { throw new HException("Enum not found " . _hx_string_or_null($name1)); } $e = $this->unserializeEnum($edecl, $this->unserialize()); $this->cache->push($e); return $e; break; case 106: $name2 = $this->unserialize(); $edecl1 = $this->resolver->resolveEnum($name2); if ($edecl1 === null) { throw new HException("Enum not found " . _hx_string_or_null($name2)); } $this->pos++; $index = $this->readDigits(); $tag = _hx_array_get(Type::getEnumConstructs($edecl1), $index); if ($tag === null) { throw new HException("Unknown enum index " . _hx_string_or_null($name2) . "@" . _hx_string_rec($index, "")); } $e1 = $this->unserializeEnum($edecl1, $tag); $this->cache->push($e1); return $e1; break; case 108: $l = new HList(); $this->cache->push($l); $buf1 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $l->add($this->unserialize()); } $this->pos++; return $l; break; case 98: $h = new haxe_ds_StringMap(); $this->cache->push($h); $buf2 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s1 = $this->unserialize(); $h->set($s1, $this->unserialize()); unset($s1); } $this->pos++; return $h; break; case 113: $h1 = new haxe_ds_IntMap(); $this->cache->push($h1); $buf3 = $this->buf; $c2 = null; $p3 = $this->pos++; $c2 = ord(substr($this->buf, $p3, 1)); while ($c2 === 58) { $i = $this->readDigits(); $h1->set($i, $this->unserialize()); $p4 = $this->pos++; $c2 = ord(substr($this->buf, $p4, 1)); unset($p4); unset($i); } if ($c2 !== 104) { throw new HException("Invalid IntMap format"); } return $h1; break; case 77: $h2 = new haxe_ds_ObjectMap(); $this->cache->push($h2); $buf4 = $this->buf; while (ord(substr($this->buf, $this->pos, 1)) !== 104) { $s2 = $this->unserialize(); $h2->set($s2, $this->unserialize()); unset($s2); } $this->pos++; return $h2; break; case 118: $d = Date::fromString(_hx_substr($this->buf, $this->pos, 19)); $this->cache->push($d); $this->pos += 19; return $d; break; case 115: $len1 = $this->readDigits(); $buf5 = $this->buf; if (haxe_Unserializer_4($this, $_g, $buf5, $len1) !== 58 || $this->length - $this->pos < $len1) { throw new HException("Invalid bytes length"); } $codes = haxe_Unserializer::$CODES; if ($codes === null) { $codes = haxe_Unserializer::initCodes(); haxe_Unserializer::$CODES = $codes; } $i1 = $this->pos; $rest = $len1 & 3; $size = null; $size = ($len1 >> 2) * 3 + haxe_Unserializer_5($this, $_g, $buf5, $codes, $i1, $len1, $rest, $size); $max = $i1 + ($len1 - $rest); $bytes = haxe_io_Bytes::alloc($size); $bpos = 0; while ($i1 < $max) { $c11 = $codes[haxe_Unserializer_6($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c21 = $codes[haxe_Unserializer_7($this, $_g, $bpos, $buf5, $bytes, $c11, $codes, $i1, $len1, $max, $rest, $size)]; $pos = $bpos++; $bytes->b[$pos] = chr($c11 << 2 | $c21 >> 4); unset($pos); $c3 = $codes[haxe_Unserializer_8($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $codes, $i1, $len1, $max, $rest, $size)]; $pos1 = $bpos++; $bytes->b[$pos1] = chr($c21 << 4 | $c3 >> 2); unset($pos1); $c4 = $codes[haxe_Unserializer_9($this, $_g, $bpos, $buf5, $bytes, $c11, $c21, $c3, $codes, $i1, $len1, $max, $rest, $size)]; $pos2 = $bpos++; $bytes->b[$pos2] = chr($c3 << 6 | $c4); unset($pos2); unset($c4, $c3, $c21, $c11); } if ($rest >= 2) { $c12 = $codes[haxe_Unserializer_10($this, $_g, $bpos, $buf5, $bytes, $codes, $i1, $len1, $max, $rest, $size)]; $c22 = $codes[haxe_Unserializer_11($this, $_g, $bpos, $buf5, $bytes, $c12, $codes, $i1, $len1, $max, $rest, $size)]; $pos3 = $bpos++; $bytes->b[$pos3] = chr($c12 << 2 | $c22 >> 4); if ($rest === 3) { $c31 = $codes[haxe_Unserializer_12($this, $_g, $bpos, $buf5, $bytes, $c12, $c22, $codes, $i1, $len1, $max, $rest, $size)]; $pos4 = $bpos++; $bytes->b[$pos4] = chr($c22 << 4 | $c31 >> 2); } } $this->pos += $len1; $this->cache->push($bytes); return $bytes; break; case 67: $name3 = $this->unserialize(); $cl1 = $this->resolver->resolveClass($name3); if ($cl1 === null) { throw new HException("Class not found " . _hx_string_or_null($name3)); } $o2 = Type::createEmptyInstance($cl1); $this->cache->push($o2); $o2->hxUnserialize($this); if (haxe_Unserializer_13($this, $_g, $cl1, $name3, $o2) !== 103) { throw new HException("Invalid custom data"); } return $o2; break; default: break; } $this->pos--; throw new HException("Invalid char " . _hx_string_or_null(_hx_char_at($this->buf, $this->pos)) . " at position " . _hx_string_rec($this->pos, "")); }
/** * Add in empty data arrays for dates with no values * * @param string $upcoming * @return void * @access private * @since 2/29/08 */ private function addEmptyDates($upcoming) { if (!count($this->data['labels'])) { return; } $i = Date::fromString(end($this->data['labels']))->plus(Duration::withDays(1)); $upcoming = Date::fromString($upcoming); while ($i->isLessThan($upcoming)) { $this->data['labels'][] = $i->yyyymmddString(); $this->data['comments'][] = 0; $this->data['edits'][] = 0; $this->data['files'][] = 0; $this->data['logins'][] = 0; $this->data['users'][] = 0; $this->data['errors'][] = 0; $i = $i->plus(Duration::withDays(1)); } }
function fromString($strDate) { // ha relative date, pl: 9000-00-00 00:10 if (preg_match("/^(8|9)(\\d{3})-(\\d{2})-(\\d{2}) ?(\\d{0,2}):?(\\d{0,2}):?(\\d{0,2})/", $strDate, $matches)) { $this->dir = $matches[1] == 8 ? Date_Ago : Date_FromNow; $this->year = (int) $matches[2]; $this->month = (int) $matches[3]; $this->day = (int) $matches[4]; if (isset($matches[5])) { $this->hour = (int) $matches[5]; } if (isset($matches[6])) { $this->minute = (int) $matches[6]; } if (isset($matches[7])) { $this->second = (int) $matches[7]; } } else { parent::fromString($strDate); } }
public function serialization() { $original = Date::fromString('2007-07-18T09:42:08 Europe/Athens'); $copy = unserialize(serialize($original)); $this->assertEquals($original, $copy); }
/** * Setup method * */ public function setUp() { $this->fixture = new MockCollection('.'); // Warning: Changing this list will make some tests fail! $this->addElement($this->fixture, new MockElement('./first.txt', 1200, Date::fromString('Oct 10 2006'), Date::fromString('Dec 14 2005'), Date::fromString('Oct 30 2005'))); $this->addElement($this->fixture, new MockElement('./second.txt', 333, Date::fromString('Oct 10 2006'), Date::fromString('Dec 24 2005'), Date::fromString('Oct 30 2005'))); $this->addElement($this->fixture, new MockElement('./third.jpg', 18882, Date::fromString('Dec 11 2003'), Date::fromString('Dec 10 2003'), Date::fromString('Dec 10 2003'))); $this->addElement($this->fixture, new MockElement('./zerobytes.png', 0, Date::fromString('Dec 11 2003'), Date::fromString('Dec 10 2003'), Date::fromString('Dec 10 2003'))); with($sub = $this->addElement($this->fixture, new MockCollection('./sub'))); $this->addElement($sub, new MockElement('./sub/IMG_6100.jpg', 531718, Date::fromString('Mar 9 2006'), Date::fromString('Mar 9 2006'), Date::fromString('Mar 9 2006'))); $this->addElement($sub, new MockElement('./sub/IMG_6100.txt', 5932, Date::fromString('Mar 13 2006'), Date::fromString('Mar 13 2006'), Date::fromString('Mar 13 2006'))); with($sec = $this->addElement($this->fixture, new MockCollection('./sub/sec'))); $this->addElement($sec, new MockElement('./sub/sec/lang.base.php', 16739, Date::fromString('Oct 11 2006'), Date::fromString('Oct 11 2006'), Date::fromString('Feb 21 2002'))); $this->addElement($sec, new MockElement('./sub/sec/__xp__.php', 8589, Date::fromString('Oct 8 2006'), Date::fromString('Oct 8 2006'), Date::fromString('Jul 23 2006'))); // Self-check $this->assertEquals($this->total, array_sum($this->sizes)); }
public function fromViewtoDom($value) { return Date::fromString($value, InputDate::DATE_TRANSFER_FORMAT); }
/** * Returns a record * * @param [:var] record * @param string field * @return [:var] record */ protected function record($record, $field = NULL) { $return = array(); foreach ($this->fields as $i => $info) { $type = $info['type']; $value = $record[$i]; if (NULL === $value) { $return[$info['name']] = NULL; continue; } switch ($type) { case 10: // DATE // DATE case 11: // TIME // TIME case 12: // DATETIME // DATETIME case 14: // NEWDATETIME // NEWDATETIME case 7: // TIMESTAMP $return[$info['name']] = NULL === $value || '0000-00-00 00:00:00' === $value ? NULL : Date::fromString($value, $this->tz); break; case 8: // LONGLONG // LONGLONG case 3: // LONG // LONG case 9: // INT24 // INT24 case 2: // SHORT // SHORT case 1: // TINY // TINY case 16: // BIT if ($value <= LONG_MAX && $value >= LONG_MIN) { $return[$info['name']] = (int) $value; } else { $return[$info['name']] = (double) $value; } break; case 4: // FLOAT // FLOAT case 5: // DOUBLE // DOUBLE case 0: // DECIMAL // DECIMAL case 246: // NEWDECIMAL $return[$info['name']] = (double) $value; break; case 253: // CHAR $return[$info['name']] = (string) $value; break; default: $return[$info['name']] = $value; } } return NULL === $field ? $return : $return[$field]; }
/** * Recursively deserialize data for the given node. * * @param xml.Node node * @return var * @throws lang.IllegalArgumentException if the data cannot be deserialized * @throws lang.ClassNotFoundException in case a XP object's class could not be loaded * @throws xml.XMLFormatException */ protected function _unmarshall(Node $node) { // value without type is supposed to be string (XML-RPC specs) if ('value' == $node->getName() && !isset($node->children[0])) { return (string) $node->getContent(); } if (!isset($node->children[0])) { throw new XMLFormatException('Tried to access nonexistant node.'); } // Simple form: If no subnode indicating the type exists, the type // is string, e.g. <value>Test</value> if (!$node->hasChildren()) { return (string) $node->getContent(); } // Long form - with subnode, the type is derived from the node's name, // e.g. <value><string>Test</string></value>. $c = $node->nodeAt(0); switch ($c->getName()) { case 'struct': $ret = array(); foreach ($c->getChildren() as $child) { $data = array(); $data[$child->nodeAt(0)->getName()] = $child->nodeAt(0); $data[$child->nodeAt(1)->getName()] = $child->nodeAt(1); $ret[$data['name']->getContent()] = $this->_unmarshall($data['value']); unset($data); } if (!isset($ret['__xp_class'])) { return $ret; } // Check whether this is a XP object. If so, load the class and // create an instance without invoking the constructor. $fields = XPClass::forName($ret['__xp_class'])->getFields(); $cname = array_search($ret['__xp_class'], xp::$cn, TRUE); $s = ''; $n = 0; foreach ($fields as $field) { if (!isset($ret[$field->getName()])) { continue; } $m = $field->getModifiers(); if ($m & MODIFIER_STATIC) { continue; } else { if ($m & MODIFIER_PUBLIC) { $name = $field->getName(); } else { if ($m & MODIFIER_PROTECTED) { $name = "*" . $field->getName(); } else { if ($m & MODIFIER_PRIVATE) { $name = "" . array_search($field->getDeclaringClass()->getName(), xp::$cn, TRUE) . "" . $field->getName(); } } } } $s .= 's:' . strlen($name) . ':"' . $name . '";' . serialize($ret[$field->getName()]); $n++; } return unserialize('O:' . strlen($cname) . ':"' . $cname . '":' . $n . ':{' . $s . '}'); case 'array': $ret = array(); foreach ($c->nodeAt(0)->getChildren() as $child) { $ret[] = $this->_unmarshall($child); } return $ret; case 'int': case 'i4': return (int) $c->getContent(); case 'double': return (double) $c->getContent(); case 'boolean': return (bool) $c->getContent(); case 'string': return (string) $c->getContent(); case 'dateTime.iso8601': return Date::fromString($c->getContent()); case 'nil': return NULL; case 'base64': return new Bytes(base64_decode($c->getContent())); default: throw new IllegalArgumentException('Could not decode node as its type is not supported: ' . $c->getName()); } }