From ec9497a66134255a328baabb6b0407c6cf703cca Mon Sep 17 00:00:00 2001 From: Michael Schlueter Date: Mon, 1 Apr 2024 14:24:09 +0200 Subject: [PATCH] removed duplicate __serialize and __unserialize --- .gitignore | 1 + lib/Horde/Imap/Client/Base.php | 24 -------- lib/Horde/Imap/Client/Data/Acl.php | 17 +----- lib/Horde/Imap/Client/Data/AclRights.php | 13 ----- lib/Horde/Imap/Client/Data/Capability.php | 15 +---- lib/Horde/Imap/Client/Data/Envelope.php | 20 ------- lib/Horde/Imap/Client/Data/Namespace.php | 13 ----- lib/Horde/Imap/Client/Data/SearchCharset.php | 13 ----- lib/Horde/Imap/Client/Data/Thread.php | 13 ----- lib/Horde/Imap/Client/Ids.php | 58 -------------------- lib/Horde/Imap/Client/Ids/Map.php | 25 --------- lib/Horde/Imap/Client/Mailbox.php | 13 ----- lib/Horde/Imap/Client/Search/Query.php | 41 -------------- lib/Horde/Imap/Client/Url.php | 13 ----- lib/Horde/Imap/Client/Url/Base.php | 13 ----- 15 files changed, 3 insertions(+), 289 deletions(-) diff --git a/.gitignore b/.gitignore index 4e78ae362..433789ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .cache .project .settings +.vscode nbproject/ *~ .#* diff --git a/lib/Horde/Imap/Client/Base.php b/lib/Horde/Imap/Client/Base.php index 6f20a46ea..f6eb80ee2 100644 --- a/lib/Horde/Imap/Client/Base.php +++ b/lib/Horde/Imap/Client/Base.php @@ -402,30 +402,6 @@ public function __unserialize(array $data) $this->_initOb(); } - /** - * @return array - */ - public function __serialize() - { - return array( - 'i' => $this->_init, - 'p' => $this->_params, - 'v' => self::VERSION - ); - } - - public function __unserialize(array $data) - { - if (empty($data['v']) || $data['v'] != self::VERSION) { - throw new Exception('Cache version change'); - } - - $this->_init = $data['i']; - $this->_params = $data['p']; - - $this->_initOb(); - } - /** */ public function __get($name) diff --git a/lib/Horde/Imap/Client/Data/Acl.php b/lib/Horde/Imap/Client/Data/Acl.php index bfd6455d6..dd71c9fe9 100644 --- a/lib/Horde/Imap/Client/Data/Acl.php +++ b/lib/Horde/Imap/Client/Data/Acl.php @@ -170,22 +170,7 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return array( - 'rights' => $this->_rights - ); - } - - public function __unserialize(array $data) - { - $this->_rights = $data['rights']; - } - - /** + /** * @return array */ public function __serialize() diff --git a/lib/Horde/Imap/Client/Data/AclRights.php b/lib/Horde/Imap/Client/Data/AclRights.php index 0eb1fa690..3a5e3b256 100644 --- a/lib/Horde/Imap/Client/Data/AclRights.php +++ b/lib/Horde/Imap/Client/Data/AclRights.php @@ -215,19 +215,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return [$this->_required, $this->_optional]; - } - - public function __unserialize(array $data) - { - list($this->_required, $this->_optional) = $data; - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Data/Capability.php b/lib/Horde/Imap/Client/Data/Capability.php index d13fa2786..c1e18eb39 100644 --- a/lib/Horde/Imap/Client/Data/Capability.php +++ b/lib/Horde/Imap/Client/Data/Capability.php @@ -215,20 +215,7 @@ public function unserialize($data) if (!is_array($data)) { throw new Exception('Cache version change.'); } - $this->__unserialize(); - } - - /** - * @return array - */ - public function __serialize() - { - return $this->_data; - } - - public function __unserialize(array $data) - { - $this->_data = $data; + $this->__unserialize($data); } /** diff --git a/lib/Horde/Imap/Client/Data/Envelope.php b/lib/Horde/Imap/Client/Data/Envelope.php index cbec4dfb9..098b2e4d1 100644 --- a/lib/Horde/Imap/Client/Data/Envelope.php +++ b/lib/Horde/Imap/Client/Data/Envelope.php @@ -235,24 +235,4 @@ public function __unserialize(array $data) $this->_data = $data['d']; } - /** - * @return array - */ - public function __serialize() - { - return array( - 'd' => $this->_data, - 'v' => self::VERSION, - ); - } - - public function __unserialize(array $data) - { - if (empty($data['v']) || $data['v'] != self::VERSION) { - throw new Exception('Cache version change'); - } - - $this->_data = $data['d']; - } - } diff --git a/lib/Horde/Imap/Client/Data/Namespace.php b/lib/Horde/Imap/Client/Data/Namespace.php index fdce7c3a9..61e3f35f9 100644 --- a/lib/Horde/Imap/Client/Data/Namespace.php +++ b/lib/Horde/Imap/Client/Data/Namespace.php @@ -157,17 +157,4 @@ public function __unserialize(array $data) $this->_data = $data; } - /** - * @return array - */ - public function __serialize() - { - return $this->_data; - } - - public function __unserialize(array $data) - { - $this->_data = $data; - } - } diff --git a/lib/Horde/Imap/Client/Data/SearchCharset.php b/lib/Horde/Imap/Client/Data/SearchCharset.php index f542e7f85..181c285f9 100644 --- a/lib/Horde/Imap/Client/Data/SearchCharset.php +++ b/lib/Horde/Imap/Client/Data/SearchCharset.php @@ -195,17 +195,4 @@ public function __unserialize(array $data) $this->_charsets = $data; } - /** - * @return array - */ - public function __serialize() - { - return $this->_charsets; - } - - public function __unserialize(array $data) - { - $this->_charsets = $data; - } - } diff --git a/lib/Horde/Imap/Client/Data/Thread.php b/lib/Horde/Imap/Client/Data/Thread.php index 4e204a79c..69fc6c489 100644 --- a/lib/Horde/Imap/Client/Data/Thread.php +++ b/lib/Horde/Imap/Client/Data/Thread.php @@ -197,19 +197,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return [$this->_thread, $this->_type]; - } - - public function __unserialize(array $data) - { - list($this->_thread, $this->_type) = $data; - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Ids.php b/lib/Horde/Imap/Client/Ids.php index 2bd4350dc..b75eeba36 100644 --- a/lib/Horde/Imap/Client/Ids.php +++ b/lib/Horde/Imap/Client/Ids.php @@ -450,64 +450,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - */ - public function __serialize() - { - $save = array(); - - if ($this->duplicates) { - $save['d'] = 1; - } - - if ($this->_sequence) { - $save['s'] = 1; - } - - if ($this->_sorted) { - $save['is'] = 1; - } - - switch ($this->_ids) { - case self::ALL: - $save['a'] = true; - break; - - case self::LARGEST: - $save['l'] = true; - break; - - case self::SEARCH_RES: - $save['sr'] = true; - break; - - default: - $save['i'] = strval($this); - break; - } - - return $save; - } - - /** - */ - public function __unserialize($data) - { - $this->duplicates = !empty($data['d']); - $this->_sequence = !empty($data['s']); - $this->_sorted = !empty($data['is']); - - if (isset($data['a'])) { - $this->_ids = self::ALL; - } elseif (isset($data['l'])) { - $this->_ids = self::LARGEST; - } elseif (isset($data['sr'])) { - $this->_ids = self::SEARCH_RES; - } elseif (isset($data['i'])) { - $this->add($data['i']); - } - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Ids/Map.php b/lib/Horde/Imap/Client/Ids/Map.php index 46ff201ae..675c477d3 100644 --- a/lib/Horde/Imap/Client/Ids/Map.php +++ b/lib/Horde/Imap/Client/Ids/Map.php @@ -228,31 +228,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - */ - public function __serialize() - { - /* Sort before storing; provides more compressible representation. */ - $this->sort(); - - return [ - strval(new Horde_Imap_Client_Ids(array_keys($this->_ids))), - strval(new Horde_Imap_Client_Ids(array_values($this->_ids))) - ]; - } - - /** - */ - public function __unserialize($data) - { - $keys = new Horde_Imap_Client_Ids($data[0]); - $vals = new Horde_Imap_Client_Ids($data[1]); - $this->_ids = array_combine($keys->ids, $vals->ids); - - /* Guaranteed to be sorted if unserializing. */ - $this->_sorted = true; - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Mailbox.php b/lib/Horde/Imap/Client/Mailbox.php index d146002c9..8f9417539 100644 --- a/lib/Horde/Imap/Client/Mailbox.php +++ b/lib/Horde/Imap/Client/Mailbox.php @@ -148,19 +148,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return [$this->_utf7imap, $this->_utf8]; - } - - public function __unserialize(array $data) - { - list($this->_utf7imap, $this->_utf8) = $data; - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Search/Query.php b/lib/Horde/Imap/Client/Search/Query.php index b968d6ec5..aa05eafa2 100644 --- a/lib/Horde/Imap/Client/Search/Query.php +++ b/lib/Horde/Imap/Client/Search/Query.php @@ -874,47 +874,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * Serialization. - * - * @return string Serialized data. - */ - public function __serialize() - { - $data = array( - // Serialized data ID. - self::VERSION, - $this->_search - ); - - if (!is_null($this->_charset)) { - $data[] = $this->_charset; - } - - return $data; - } - - /** - * Unserialization. - * - * @param string $data Serialized data. - * - * @throws Exception - */ - public function __unserialize($data) - { - if (!is_array($data) || - !isset($data[0]) || - ($data[0] != self::VERSION)) { - throw new Exception('Cache version change'); - } - - $this->_search = $data[1]; - if (isset($data[2])) { - $this->_charset = $data[2]; - } - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Url.php b/lib/Horde/Imap/Client/Url.php index f27e0296a..d02052755 100644 --- a/lib/Horde/Imap/Client/Url.php +++ b/lib/Horde/Imap/Client/Url.php @@ -303,19 +303,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return array((string)$this); - } - - public function __unserialize(array $data) - { - $this->_parse($data[0]); - } - /** * @return array */ diff --git a/lib/Horde/Imap/Client/Url/Base.php b/lib/Horde/Imap/Client/Url/Base.php index 97c05bb32..d2a7fdad2 100644 --- a/lib/Horde/Imap/Client/Url/Base.php +++ b/lib/Horde/Imap/Client/Url/Base.php @@ -174,19 +174,6 @@ public function unserialize($data) $this->__unserialize($data); } - /** - * @return array - */ - public function __serialize() - { - return array((string)$this); - } - - public function __unserialize(array $data) - { - $this->_parse($data[0]); - } - /** * @return array */