/** * The magic wakeup method will be called by PHP's runtime environment when * a serialized instance of this class was unserialized. This implementation * of the wakeup method will register this object in the the global class * context. * * @return void */ public function __wakeup() { parent::__wakeup(); $this->context->registerTrait($this); }
/** * testMagicWakeupSetsSourceFileOnChildMethods * * @return void */ public function testMagicWakeupSetsSourceFileOnChildMethods() { $class = new PHP_Depend_Code_Class(__CLASS__); $class->setCache(new PHP_Depend_Util_Cache_Driver_Memory()); $method = new PHP_Depend_Code_Method(__FUNCTION__); $class->addMethod($method); $class->setContext($this->getMock('PHP_Depend_Builder_Context')); $file = new PHP_Depend_Code_File(__FILE__); $class->setSourceFile($file); $class->__wakeup(); self::assertSame($file, $method->getSourceFile()); }
/** * testMagicWakeupSetsParentOnChildMethods * * @return void * @group pdepend * @group pdepend::code * @group unittest */ public function testMagicWakeupSetsParentOnChildMethods() { $class = new PHP_Depend_Code_Class(__CLASS__); $method = new PHP_Depend_Code_Method(__FUNCTION__); $class->addMethod($method); $class->setContext($this->getMock('PHP_Depend_Builder_Context')); $method->setParent(null); $class->__wakeup(); self::assertSame($class, $method->getParent()); }