Skip to content

Commit

Permalink
fixed deprecate warnings with PHP8.1 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlue committed Sep 19, 2023
1 parent a2d4e6a commit 57bfe1f
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 78 deletions.
21 changes: 16 additions & 5 deletions lib/Compose/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ public function viewUrl()
/**
*/
public function serialize()
{
return array_shift($this->__serialize());
}

public function __serialize(): array
{
/* Don't store Mime_Part data. Can't use clone here ATM, since there
* appears to be a PHP bug. Since this is an object specific to IMP
Expand All @@ -196,7 +201,9 @@ public function serialize()
$this->_part->clearContents();
$this->_isBuilt = false;

return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
return
[
$GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_composeCache,
$this->id,
Expand All @@ -207,13 +214,18 @@ public function serialize()
), array(
'compression' => false,
'phpob' => true
)
);
))
];
}

/**
*/
public function unserialize($data)
{
$this->__unserialize([$data]);
}

public function __unserialize(array $data): void
{
list(
$this->_composeCache,
Expand All @@ -222,7 +234,6 @@ public function unserialize($data)
$this->_part,
$this->related,
$this->_uuid
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack(array_shift($data));
}

}
11 changes: 10 additions & 1 deletion lib/Flag/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,21 @@ public function serialize()
{
return $this->_bgcolor;
}

public function __serialize(): array
{
return [
$this->_bgcolor
];
}
/**
*/
public function unserialize($data)
{
$this->_bgcolor = $data;
}

public function __unserialize(array $data): void
{
$this->_bgcolor = $data[0];
}
}
25 changes: 18 additions & 7 deletions lib/Flag/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,33 @@ protected function _getLabel()
*/
public function serialize()
{
return json_encode(array(
parent::serialize(),
$this->_label,
$this->_imapflag
));
return array_shift($this->__serialize());
}
public function __serialize(): array
{
return
[
json_encode(array(
parent::serialize(),
$this->_label,
$this->_imapflag
))
];
}

/**
*/
public function unserialize($data)
{
$data = json_decode($data, true);
$this->__unserialize([$data]);
}
public function __unserialize(array $data): void
{
$data = json_decode($data[0], true);

parent::unserialize($data[0]);
$this->_label = $data[1];
$this->_imapflag = $data[2];
}

}
}
13 changes: 11 additions & 2 deletions lib/Ftree/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,21 @@ public function serialize()
{
return $this->_id;
}

public function __serialize(): array
{
return
[
$this->_id
];
}
/**
*/
public function unserialize($data)
{
$this->_id = $data;
}

public function __unserialize(array $data): void
{
$this->_id = $data[0];
}
}
33 changes: 22 additions & 11 deletions lib/Ftree/Eltdiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,37 @@ public function clear()
*/
public function serialize()
{
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->track,
$this->_changes
),
array(
'compression' => false,
'phpob' => false
)
);
return array_shift($this->__serialize());
}
public function __serialize(): array
{
return
[
$GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->track,
$this->_changes
),
array(
'compression' => false,
'phpob' => false
)
)
];
}

/**
*/
public function unserialize($data)
{
$this->__unserialize([$data]);
}
public function __unserialize(array $data): void
{
list(
$this->track,
$this->_changes
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack(array_shift($data));
}

}
38 changes: 25 additions & 13 deletions lib/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,28 +943,40 @@ public static function loadServerConfig($server = null)
*/
public function serialize()
{
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_ob,
$this->_id,
$this->_config
),
array(
'compression' => false,
'phpob' => true
return array_shift($this->__serialize());
}
public function __serialize(): array
{
return
[
$GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_ob,
$this->_id,
$this->_config
),
array(
'compression' => false,
'phpob' => true
)
)
);
];
}

/**
* @throws Horde_Pack_Exception
*/
public function unserialize($data)
{
$this->__unserialize([$data]);
}

public function __unserialize(array $data): void
{
list(
$this->_ob,
$this->_id,
$this->_config
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack(array_shift($data));

}

}
16 changes: 13 additions & 3 deletions lib/Imap/Cache/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,24 @@ public function __call($name, $arguments)
*/
public function serialize()
{
return json_encode($this->_params);
return array_shift($this->__serialize());
}
public function __serialize(): array
{
return
[
json_encode($this->_params)
];
}

/**
*/
public function unserialize($data)
{
$this->_initOb(json_decode($data, true));
$this->__unserialize([$data]);
}
public function __unserialize(array $data): void
{
$this->_initOb(json_decode($data[0], true));
}

}
31 changes: 21 additions & 10 deletions lib/Imap/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function __get($name)

case 'maildomain':
/* Sanity checking - this should be null, not empty string. */
if (!strlen($out)) {
if (!is_null($out) && !strlen($out)) {
$out = null;
}
break;
Expand Down Expand Up @@ -376,31 +376,42 @@ public function __unset($name)
/**
*/
public function serialize()
{
return array_shift($this->__serialize());
}
public function __serialize(): array
{
global $injector, $session;

if (!empty($this->_passwords)) {
$session->set('imp', self::PASSWORDS_KEY, $this->_passwords, $session::ENCRYPT);
}

return $injector->getInstance('Horde_Pack')->pack(
array_filter($this->_config),
array(
'compression' => false,
'phpob' => false
return
[
$injector->getInstance('Horde_Pack')->pack(
array_filter($this->_config),
array(
'compression' => false,
'phpob' => false
)
)
);
}
];

}
/**
*/
public function unserialize($data)
{
$this->__unserialize([$data]);
}
public function __unserialize(array $data): void
{
global $injector, $session;

$this->_config = $injector->getInstance('Horde_Pack')->unpack($data);
$this->_config = $injector->getInstance('Horde_Pack')->unpack(array_shift($data));

$this->_passwords = $session->get('imp', self::PASSWORDS_KEY, $session::TYPE_ARRAY);
}

}
}
18 changes: 14 additions & 4 deletions lib/Imap/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function getPassword()
/**
*/
public function serialize()
{
return array_shift($this->__serialize());
}
public function __serialize(): array
{
global $session;

Expand All @@ -73,15 +77,21 @@ public function serialize()

$session->set('imp', self::PASSWORD_KEY . '/' . $this->_id, $this->_password, $session::ENCRYPT);

return $this->_id;
return
[
$this->_id
];
}

/**
* @throws RuntimeException
*/
public function unserialize($data)
{
$this->_id = $data;
$this->__unserialize([$data]);
}
public function __unserialize(array $data): void
{
$this->_id = $data[0];

$password = $GLOBALS['session']->get(
'imp',
Expand All @@ -94,6 +104,6 @@ public function unserialize($data)
);
}
$this->_password = $password;
}

}
}

0 comments on commit 57bfe1f

Please sign in to comment.