Skip to content

Commit

Permalink
! fix a few 8.1 depreciation notices
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Jul 7, 2022
1 parent a15f343 commit 49e7ddc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion sources/ElkArte/BBC/BBCParser.php
Expand Up @@ -1639,7 +1639,7 @@ protected function getOpenedTags($tags_only = false)
*/
protected function trimWhiteSpace($offset = null)
{
if (preg_match('~(<br />|&nbsp;|\s)*~', $this->message, $matches, null, $offset) !== 0 && isset($matches[0]) && $matches[0] !== '')
if (preg_match('~(<br />|&nbsp;|\s)*~', $this->message, $matches, 0, $offset) !== 0 && isset($matches[0]) && $matches[0] !== '')
{
$this->message = substr_replace($this->message, '', $offset, strlen($matches[0]));
}
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Censor.php
Expand Up @@ -95,7 +95,7 @@ protected function setVulgarProper(array $vulgar, array $proper)
*/
public function censor($text, $force = false)
{
if (empty($this->vulgar) || (!$force && !$this->doCensor()))
if (empty($text) || empty($this->vulgar) || (!$force && !$this->doCensor()))
{
return $text;
}
Expand Down
17 changes: 9 additions & 8 deletions sources/ElkArte/Sessions/SessionHandler/DatabaseHandler.php
Expand Up @@ -30,14 +30,14 @@ class DatabaseHandler extends \SessionHandler
*
* @var \ElkArte\Database\QueryInterface
*/
protected $_db = null;
protected $_db;

/**
* The modSettings
*
* @var object
*/
protected $_modSettings = array();
protected $_modSettings = [];

/**
* Make "global" items available to the class
Expand All @@ -56,7 +56,7 @@ public function __construct($db = null)
/**
* {@inheritdoc}
*/
public function destroy($sessionId)
public function destroy($sessionId) : bool
{
// Better safe than sorry
if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $sessionId) == 0)
Expand All @@ -79,6 +79,7 @@ public function destroy($sessionId)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function gc($maxLifetime)
{
// Just set to the default or lower? Ignore it for a higher value. (hopefully)
Expand All @@ -102,7 +103,7 @@ public function gc($maxLifetime)
/**
* {@inheritdoc}
*/
public function read($sessionId)
public function read($sessionId) : string
{
if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $sessionId) == 0)
{
Expand All @@ -128,7 +129,7 @@ public function read($sessionId)
/**
* {@inheritdoc}
*/
public function write($sessionId, $data)
public function write($sessionId, $data) : bool
{
if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $sessionId) == 0)
{
Expand All @@ -138,9 +139,9 @@ public function write($sessionId, $data)
// Update the session data, replace if necessary
$this->_db->replace(
'{db_prefix}sessions',
array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'),
array($sessionId, $data, time()),
array('session_id')
['session_id' => 'string', 'data' => 'string', 'last_update' => 'int'],
[$sessionId, $data, time()],
['session_id']
);

return true;
Expand Down
5 changes: 5 additions & 0 deletions sources/ElkArte/Util.php
Expand Up @@ -295,6 +295,11 @@ public static function strlen($string)
{
global $modSettings;

if (empty($string))
{
return 0;
}

if (empty($modSettings['disableEntityCheck']))
{
$ent_list = '&(#\d{1,7}|quot|amp|lt|gt|nbsp);';
Expand Down
12 changes: 6 additions & 6 deletions sources/ElkArte/ValuesContainer.php
Expand Up @@ -27,7 +27,7 @@ class ValuesContainer implements \ArrayAccess
*
* @var mixed[]
*/
protected $data = array();
protected $data = [];

/**
* Constructor
Expand Down Expand Up @@ -110,7 +110,7 @@ public function __isset($key)
* @param mixed|mixed[] $offset
* @param string $value
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value) : void
{
if (is_null($offset))
{
Expand All @@ -128,7 +128,7 @@ public function offsetSet($offset, $value)
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
public function offsetExists($offset) : bool
{
return isset($this->data[$offset]);
}
Expand All @@ -138,7 +138,7 @@ public function offsetExists($offset)
*
* @param string|int $offset
*/
public function offsetUnset($offset)
public function offsetUnset($offset) : void
{
unset($this->data[$offset]);
}
Expand All @@ -147,9 +147,9 @@ public function offsetUnset($offset)
* Returns the value associated to a certain offset.
*
* @param string|int $offset
* @return mixed|array
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet($offset) : mixed
{
return $this->data[$offset] ?? null;
}
Expand Down
4 changes: 2 additions & 2 deletions sources/ElkArte/ValuesContainerReadOnly.php
Expand Up @@ -41,7 +41,7 @@ public function __set($key, $val)
* @param mixed|mixed[] $offset
* @param string $value
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value) : void
{
}

Expand All @@ -51,7 +51,7 @@ public function offsetSet($offset, $value)
*
* @param string|int $offset
*/
public function offsetUnset($offset)
public function offsetUnset($offset) : void
{
}

Expand Down
4 changes: 2 additions & 2 deletions sources/Load.php
Expand Up @@ -1296,12 +1296,12 @@ function determineAvatar($profile)
return [];
}

$avatar_protocol = substr(strtolower($profile['avatar']), 0, 7);
$avatar_protocol = empty($profile['avatar']) ? '' : strtolower(substr($profile['avatar'], 0, 7));
$alt = $profile['member_name'] ?? '';

// Build the gravatar request once.
$gravatar = '//www.gravatar.com/avatar/' .
hash('md5', strtolower($profile['email_address'])) .
hash('md5', strtolower($profile['email_address'] ?? '')) .
'?s=' . $modSettings['avatar_max_height'] .
(!empty($modSettings['gravatar_rating']) ? ('&amp;r=' . $modSettings['gravatar_rating']) : '') .
((!empty($modSettings['gravatar_default']) && $modSettings['gravatar_default'] !== 'none') ? ('&amp;d=' . $modSettings['gravatar_default']) : '');
Expand Down

0 comments on commit 49e7ddc

Please sign in to comment.