Example #1
0
 /**
  * @inheritdoc
  */
 public function restoreWithoutProxyMarker($a)
 {
     if (is_object($a)) {
         if ($this->isTransferObject($a)) {
             $r = new \ReflectionClass($a);
             foreach ($r->getProperties() as $prop) {
                 $prop->setAccessible(true);
                 $pval = $prop->getValue($a);
                 if ($pval instanceof Marker) {
                     $pval = $this->refPool->getObj($pval->getRef());
                 } else {
                     $pval = $this->restoreWithoutProxyMarker($pval);
                 }
                 $prop->setValue($a, $pval);
             }
         }
     } else {
         if (is_array($a)) {
             foreach ($a as &$val) {
                 $val = $this->restoreWithoutProxyMarker($val);
             }
         }
     }
     return $a;
 }
Example #2
0
 public function testRefPool()
 {
     $pool = new RefPool();
     $a = new \stdClass();
     $a->val = 'a';
     $b = new \stdClass();
     $b->val = 'b';
     $aref = $pool->pushRef($a);
     $bref = $pool->pushRef($b);
     $bref2 = $pool->pushRef($b);
     $this->assertEquals($bref, $bref2);
     $this->assertNotEquals($aref, $bref);
     $this->assertEquals($a, $pool->getObj($aref));
     $this->assertEquals($b, $pool->getObj($bref));
     $this->assertTrue($pool->exists($aref));
     $this->assertFalse($pool->exists(99999));
     $this->assertNotEquals($pool->pushRef(new \stdClass()), $pool->pushRef(new \stdClass()));
 }