Opis\Closure\SerializableClosure::unserialize PHP Метод

unserialize() публичный Метод

Implementation of Serializable::unserialize()
public unserialize ( string $data )
$data string Serialized data
    public function unserialize($data)
    {
        ClosureStream::register();
        if (!static::supportBinding()) {
            $this->unserializePHP53($data);
            return;
        }
        $this->code = unserialize($data);
        if ($this->code['use']) {
            $this->code['use'] = array_map(array($this, 'mapPointers'), $this->code['use']);
            extract($this->code['use'], EXTR_OVERWRITE | EXTR_REFS);
        }
        $this->closure = (include ClosureStream::STREAM_PROTO . '://' . $this->code['function']);
        if ($this->code['this'] === $this) {
            $this->code['this'] = null;
        }
        if ($this->code['scope'] !== null || $this->code['this'] !== null) {
            if ($this->code['this'] !== null) {
                $this->isBound = $this->serializeThis = true;
            }
            $this->closure = $this->closure->bindTo($this->code['this'], $this->code['scope']);
        }
        $this->code = $this->code['function'];
    }

Usage Example

Пример #1
0
 /**
  * Override unserialize method
  *
  * @param   string $data Serialized data
  */
 public function unserialize($data)
 {
     if (static::$securityProvider === null) {
         throw new RuntimeException('You must set a security provider in order to use this class');
     }
     $data = unserialize($data);
     if (false === ($data =& static::$securityProvider->verify($data))) {
         throw new SecurityException("Your serialized closure might have been modified and it's unsafe to be unserialized." . "Make sure you are using the same security provider, with the same settings, " . "both for serialization and unserialization.");
     }
     parent::unserialize($data);
 }