Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 deprecation notices #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Horde/Mail/Rfc822.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ protected function _parseAddrSpec()
if ($this->_curr() == '@') {
try {
$this->_rfc822ParseDomain($host);
if (strlen($host)) {
if (!empty($host)) {
$ob->host = $host;
}
} catch (Horde_Mail_Exception $e) {
Expand Down Expand Up @@ -647,7 +647,7 @@ protected function _rfc822ParseAtomOrDot(&$str)
/* TODO: Optimize by duplicating rfc822IsAtext code here */
!$this->_rfc822IsAtext($chr, ',<:')) {
$this->_rfc822SkipLwsp();
if (!$this->_params['validate']) {
if (!$this->_params['validate'] && $str !== null) {
$str = trim($str);
}
return;
Expand Down
12 changes: 6 additions & 6 deletions lib/Horde/Mail/Rfc822/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __set($name, $value)
break;

case 'personal':
$this->_personal = strlen($value)
$this->_personal = !empty($value)
? Horde_Mime::decode($value)
: null;
break;
Expand Down Expand Up @@ -144,15 +144,15 @@ public function __get($name)
: $this->_personal;

case 'personal':
return (strcasecmp($this->_personal, $this->bare_address) === 0)
return $this->_personal === null || (strcasecmp($this->_personal, $this->bare_address) === 0)
? null
: $this->_personal;

case 'personal_encoded':
return Horde_Mime::encode($this->personal);

case 'valid':
return (bool)strlen($this->mailbox);
return !empty($this->mailbox);
}
}

Expand All @@ -164,11 +164,11 @@ protected function _writeAddress($opts)

$address = $rfc822->encode($this->mailbox, 'address');
$host = empty($opts['idn']) ? $this->host : $this->host_idn;
if (strlen($host)) {
if (!empty($host)) {
$address .= '@' . $host;
}
$personal = $this->personal;
if (strlen($personal)) {
if (!empty($personal)) {
if (!empty($opts['encode'])) {
$personal = Horde_Mime::encode($this->personal, $opts['encode']);
}
Expand All @@ -182,7 +182,7 @@ protected function _writeAddress($opts)
}
}

return (strlen($personal) && ($personal != $address))
return (!empty($personal) && ($personal != $address))
? ltrim($personal) . ' <' . $address . '>'
: $address;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Horde/Mail/Rfc822/Identification.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function __construct($value = null)
/**
* Parse an identification header.
*
* @param string $value Identification field value to parse.
* @param string|null $value Identification field value to parse.
*/
public function parse($value)
{
if (!strlen($value)) {
if (empty($value)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Horde/Mail/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function parseRecipients($recipients)
protected function _sanitizeHeaders($headers)
{
foreach (array_diff(array_keys($headers), array('_raw')) as $key) {
$headers[$key] = preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', null, $headers[$key]);
$headers[$key] = preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', '', $headers[$key]);
}

return $headers;
Expand Down Expand Up @@ -251,7 +251,7 @@ protected function _getFrom($from, $headers)
}
}

if (!strlen($from)) {
if (empty($from)) {
throw new Horde_Mail_Exception('No from address provided.');
}

Expand Down