All pastes #636996 Raw Edit

ClassStore.class.php

public php v1 · immutable
#636996 ·published 2007-07-28 12:51 UTC
rendered paste body
class ClassStore{  private $nombre;  private $statics;  function __construct($nombre){    $this->nombre=$nombre;  }  function set($nombre,$valor){    $this->statics[$nombre]=$valor;  }  function __wakeup(){    call_user_func(array($this->nombre,'__restoreStatics'),$this->statics);    call_user_func(array($this->nombre,'__wakeupClass'));  }  static function __storeStatics(){    $classes=get_declared_classes();    foreach($classes as $name){      $reflejo=new ReflectionClass($name);      if($reflejo->hasMethod('__restoreStatics')){        $method=$reflejo->getMethod('__restoreStatics');        if($method->getDeclaringClass()->getName()===$name){          if($reflejo->hasMethod('__sleepClass'))            call_user_func(array($name,'__sleepClass'));          if(empty($_SESSION["__statics"]))            $_SESSION["__statics"]=array();          if(empty($_SESSION["__statics"][$name]))            $_SESSION["__statics"][$name]=new ClassStore($name);          $properties=$reflejo->getProperties();          foreach($properties as $p) if($p->isStatic() && $p->getDeclaringClass()->getName()===$name){            $valor=$p->getValue();            if( !is_resource($valor))              $_SESSION["__statics"][$name]->set($p->getName(),$valor);          }        }      }    }  }}