Commit 4d2631df authored by catch's avatar catch
Browse files

Issue #3212021 by andypost, heni_deepak, Ayesh, daffie: [PHP 8.1] Serializable...

Issue #3212021 by andypost, heni_deepak, Ayesh, daffie: [PHP 8.1] Serializable interface is deprecated
parent 70d64417
Loading
Loading
Loading
Loading
+19 −6
Changes for core/lib/Drupal/Core/Menu/MenuTreeParameters.php: 19 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -212,6 +212,21 @@ public function excludeRoot() {
   * {@inheritdoc}
   */
  public function serialize() {
    return serialize($this->__serialize());
  }

  /**
   * {@inheritdoc}
   */
  public function unserialize($serialized) {
    $this->__unserialize(unserialize($serialized));
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function __serialize(): array {
    // Enforce type consistency for all the internal properties of this object.
    $this->root = (string) $this->root;
    $this->minDepth = $this->minDepth !== NULL ? (int) $this->minDepth : NULL;
@@ -222,25 +237,23 @@ public function serialize() {
    sort($this->expandedParents);
    asort($this->conditions);

    return serialize([
    return [
      'root' => $this->root,
      'minDepth' => $this->minDepth,
      'maxDepth' => $this->maxDepth,
      'expandedParents' => $this->expandedParents,
      'activeTrail' => $this->activeTrail,
      'conditions' => $this->conditions,
    ]);
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function unserialize($serialized) {
    foreach (unserialize($serialized) as $key => $value) {
  public function __unserialize(array $data): void {
    foreach ($data as $key => $value) {
      $this->{$key} = $value;
    }

    return $this;
  }

}