Beispiel #1
0
 protected function readClass()
 {
     $classname = ClassManager::getClass($this->privateReadStringWithoutTag());
     $count = (int) $this->stream->readuntil(Tags::TagOpenbrace);
     $props = new SplFixedArray($count);
     for ($i = 0; $i < $count; ++$i) {
         $props[$i] = $this->privateReadString();
     }
     $this->stream->skip(1);
     $this->classref[] = array($classname, $props);
 }
Beispiel #2
0
 public function writeObject($obj)
 {
     $class = get_class($obj);
     $alias = ClassManager::getClassAlias($class);
     if (isset($this->classref[$alias])) {
         $index = $this->classref[$alias];
     } else {
         $reflector = new ReflectionClass($obj);
         $props = $reflector->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE);
         $index = $this->writeClass($alias, $props);
     }
     $this->refer->set($obj);
     $props = $this->propsref[$index];
     $this->stream->write(Tags::TagObject . $index . Tags::TagOpenbrace);
     foreach ($props as $prop) {
         $this->serialize($prop->getValue($obj));
     }
     $this->stream->write(Tags::TagClosebrace);
 }