mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-26 18:43:33 +02:00
[ticket/17176] Resolve deprecation notices
PHPBB3-17176
This commit is contained in:
parent
daf30b89f1
commit
abd29e96b5
@ -1448,17 +1448,22 @@ function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false)
|
||||
* @param string $filename The filename basename() should be applied to
|
||||
* @return string The basenamed filename
|
||||
*/
|
||||
function utf8_basename($filename)
|
||||
function utf8_basename($filename): string
|
||||
{
|
||||
if (!$filename)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// We always check for forward slash AND backward slash
|
||||
// because they could be mixed or "sneaked" in. ;)
|
||||
// You know, never trust user input...
|
||||
if (strpos($filename, '/') !== false)
|
||||
if (str_contains($filename, '/'))
|
||||
{
|
||||
$filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1);
|
||||
}
|
||||
|
||||
if (strpos($filename, '\\') !== false)
|
||||
if (str_contains($filename, '\\'))
|
||||
{
|
||||
$filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return \ArrayIterator An iterator over all config data
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): \ArrayIterator
|
||||
{
|
||||
return new \ArrayIterator($this->config);
|
||||
}
|
||||
@ -99,7 +99,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return int Number of config options
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->config);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ class resolver implements ControllerResolverInterface
|
||||
$arguments[] = $attributes[$param->name];
|
||||
}
|
||||
}
|
||||
else if ($param->getClass() && $param->getClass()->isInstance($request))
|
||||
else if ($param->getType() && $param->getType() instanceof $request)
|
||||
{
|
||||
$arguments[] = $request;
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ class migrator
|
||||
*
|
||||
* 'effectively_installed' set and set to true if the migration was effectively_installed
|
||||
*
|
||||
* @var array|false
|
||||
* @var array
|
||||
*/
|
||||
protected $last_run_migration = false;
|
||||
protected $last_run_migration = [];
|
||||
|
||||
/**
|
||||
* The output handler. A null handler is configured by default.
|
||||
@ -193,9 +193,9 @@ class migrator
|
||||
* The array contains 'name', 'class' and 'state'. 'effectively_installed' is set
|
||||
* and set to true if the last migration was effectively_installed.
|
||||
*
|
||||
* @return array|false Last run migration information or false if no migration has been run yet
|
||||
* @return array Last run migration information or false if no migration has been run yet
|
||||
*/
|
||||
public function get_last_run_migration()
|
||||
public function get_last_run_migration(): array
|
||||
{
|
||||
return $this->last_run_migration;
|
||||
}
|
||||
@ -630,7 +630,7 @@ class migrator
|
||||
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$this->last_run_migration = false;
|
||||
$this->last_run_migration = [];
|
||||
unset($this->migration_state[$name]);
|
||||
|
||||
$this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
|
||||
|
@ -73,7 +73,7 @@ class config extends Extension
|
||||
*/
|
||||
protected function convert_30_acm_type($acm_type)
|
||||
{
|
||||
if (preg_match('#^[a-z]+$#', $acm_type))
|
||||
if (preg_match('#^[a-z]+$#', $acm_type ?? ''))
|
||||
{
|
||||
return 'phpbb\\cache\\driver\\' . $acm_type;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class ordered_service_collection extends service_collection
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): \Iterator
|
||||
{
|
||||
if (!$this->is_ordered)
|
||||
{
|
||||
@ -59,27 +59,27 @@ class ordered_service_collection extends service_collection
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetExists($index)
|
||||
public function offsetExists($key): bool
|
||||
{
|
||||
if (!$this->is_ordered)
|
||||
{
|
||||
$this->sort_services();
|
||||
}
|
||||
|
||||
return parent::offsetExists($index);
|
||||
return parent::offsetExists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetGet($index)
|
||||
public function offsetGet($key): mixed
|
||||
{
|
||||
if (!$this->is_ordered)
|
||||
{
|
||||
$this->sort_services();
|
||||
}
|
||||
|
||||
return parent::offsetGet($index);
|
||||
return parent::offsetGet($key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class service_collection extends \ArrayObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): \Iterator
|
||||
{
|
||||
return new service_collection_iterator($this);
|
||||
}
|
||||
@ -54,9 +54,9 @@ class service_collection extends \ArrayObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetGet($index)
|
||||
public function offsetGet($key): mixed
|
||||
{
|
||||
return $this->container->get($index);
|
||||
return $this->container->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ class service_collection_iterator extends \ArrayIterator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function current()
|
||||
public function current(): mixed
|
||||
{
|
||||
return $this->collection->offsetGet($this->key());
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
|
||||
*
|
||||
* @return recursive_event_filter_iterator
|
||||
*/
|
||||
public function getChildren()
|
||||
public function getChildren(): ?\RecursiveFilterIterator
|
||||
{
|
||||
$inner_iterator = $this->getInnerIterator();
|
||||
assert($inner_iterator instanceof \RecursiveIterator);
|
||||
@ -49,7 +49,7 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function accept()
|
||||
public function accept(): bool
|
||||
{
|
||||
$relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $this->current());
|
||||
$filename = $this->current()->getFilename();
|
||||
|
@ -137,7 +137,7 @@ class filespec
|
||||
$this->mimetype = $upload_ary['type'];
|
||||
|
||||
// Opera adds the name to the mime type
|
||||
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
|
||||
$this->mimetype = ($this->mimetype && str_contains($this->mimetype, '; name')) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
|
||||
|
||||
if (!$this->mimetype)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ class filespec_storage
|
||||
$this->mimetype = $upload_ary['type'];
|
||||
|
||||
// Opera adds the name to the mime type
|
||||
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
|
||||
$this->mimetype = ($this->mimetype && str_contains($this->mimetype, '; name')) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
|
||||
|
||||
if (!$this->mimetype)
|
||||
{
|
||||
|
@ -606,7 +606,7 @@ class filesystem implements filesystem_interface
|
||||
protected function phpbb_own_realpath($path)
|
||||
{
|
||||
// Replace all directory separators with '/'
|
||||
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
|
||||
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path ?: '');
|
||||
|
||||
$is_absolute_path = false;
|
||||
$path_prefix = '';
|
||||
|
@ -77,7 +77,7 @@ class finder
|
||||
);
|
||||
$this->extensions = array();
|
||||
|
||||
$this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false;
|
||||
$this->cached_queries = $this->cache ? ($this->cache->get($this->cache_name) ?: []) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ abstract class base implements \phpbb\notification\type\type_interface
|
||||
{
|
||||
// The row from the database (unless this is a new notification we're going to add)
|
||||
$this->data = $data;
|
||||
$this->data['notification_data'] = (isset($this->data['notification_data'])) ? unserialize($this->data['notification_data']) : array();
|
||||
$this->data['notification_data'] = !empty($this->data['notification_data']) ? unserialize($this->data['notification_data']) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ class type_date extends type_base
|
||||
*/
|
||||
public function validate_profile_field(&$field_value, $field_data)
|
||||
{
|
||||
$field_validate = explode('-', $field_value);
|
||||
$field_validate = explode('-', $field_value ?: '');
|
||||
|
||||
$day = (isset($field_validate[0])) ? (int) $field_validate[0] : 0;
|
||||
$month = (isset($field_validate[1])) ? (int) $field_validate[1] : 0;
|
||||
@ -184,7 +184,7 @@ class type_date extends type_base
|
||||
*/
|
||||
public function get_profile_value($field_value, $field_data)
|
||||
{
|
||||
$date = explode('-', $field_value);
|
||||
$date = explode('-', $field_value ?: '');
|
||||
$day = (isset($date[0])) ? (int) $date[0] : 0;
|
||||
$month = (isset($date[1])) ? (int) $date[1] : 0;
|
||||
$year = (isset($date[2])) ? (int) $date[2] : 0;
|
||||
|
@ -120,7 +120,7 @@ class type_int extends type_base
|
||||
*/
|
||||
public function validate_profile_field(&$field_value, $field_data)
|
||||
{
|
||||
if (trim($field_value) === '' && !$field_data['field_required'])
|
||||
if (trim($field_value ?: '') === '' && !$field_data['field_required'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -63,13 +63,9 @@ abstract class type_string_common extends type_base
|
||||
*/
|
||||
public function validate_string_profile_field($field_type, &$field_value, $field_data)
|
||||
{
|
||||
if (trim($field_value) === '' && !$field_data['field_required'])
|
||||
if (trim($field_value ?? '') === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (trim($field_value) === '' && $field_data['field_required'])
|
||||
{
|
||||
return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name']));
|
||||
return $field_data['field_required'] ? $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])) : false;
|
||||
}
|
||||
|
||||
if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen'])
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\request;
|
||||
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
/**
|
||||
* Replacement for a superglobal (like $_GET or $_POST) which calls
|
||||
* trigger_error on all operations but isset, overloads the [] operator with SPL.
|
||||
@ -74,7 +76,7 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
*
|
||||
* @return bool Whether the key on the super global exists.
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return $this->request->is_set($offset, $this->super_global);
|
||||
}
|
||||
@ -82,17 +84,17 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
/**#@+
|
||||
* Part of the \ArrayAccess implementation, will always result in a FATAL error.
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
@ -103,7 +105,7 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
* @return void
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
@ -113,7 +115,7 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
|
||||
* @return void
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*/
|
||||
public function getIterator()
|
||||
#[ReturnTypeWillChange] public function getIterator(): void
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class session
|
||||
|
||||
// First of all, get the request uri...
|
||||
$script_name = $request->escape($symfony_request->getScriptName(), true);
|
||||
$args = $request->escape(explode('&', $symfony_request->getQueryString()), true);
|
||||
$args = $request->escape(explode('&', $symfony_request->getQueryString() ?? ''), true);
|
||||
|
||||
// If we are unable to get the script name we use REQUEST_URI as a failover and note it within the page array for easier support...
|
||||
if (!$script_name)
|
||||
|
@ -17,25 +17,25 @@
|
||||
*/
|
||||
class phpbb_mock_lang implements ArrayAccess
|
||||
{
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
return $offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
}
|
||||
|
||||
public function lang()
|
||||
public function lang(): string
|
||||
{
|
||||
return implode(' ', func_get_args());
|
||||
}
|
||||
|
@ -41,13 +41,13 @@ class phpbb_mock_request extends \phpbb\request\request
|
||||
|
||||
public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST)
|
||||
{
|
||||
return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default;
|
||||
return $this->data[$super_global][$var_name] ?? $default;
|
||||
}
|
||||
|
||||
public function server($var_name, $default = '')
|
||||
{
|
||||
$super_global = \phpbb\request\request_interface::SERVER;
|
||||
return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default;
|
||||
return $this->data[$super_global][$var_name] ?? $default;
|
||||
}
|
||||
|
||||
public function header($header_name, $default = '')
|
||||
@ -115,7 +115,7 @@ class phpbb_mock_request extends \phpbb\request\request
|
||||
$this->data[\phpbb\request\request_interface::SERVER][$var_name] = $value;
|
||||
}
|
||||
|
||||
public function merge($super_global = \phpbb\request\request_interface::REQUEST, $values)
|
||||
public function merge($values, $super_global = \phpbb\request\request_interface::REQUEST): void
|
||||
{
|
||||
$this->data[$super_global] = array_merge($this->data[$super_global], $values);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||
'num_posts' => 1,
|
||||
'allow_board_notifications' => true,
|
||||
'allow_mentions' => true,
|
||||
'board_startdate' => 1692429414,
|
||||
));
|
||||
|
||||
// Event dispatcher
|
||||
@ -113,8 +114,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||
);
|
||||
|
||||
// Request
|
||||
$type_cast_helper = $this->createMock('\phpbb\request\type_cast_helper_interface');
|
||||
$request = $this->createMock('\phpbb\request\request');
|
||||
$request = new phpbb_mock_request();
|
||||
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
|
Loading…
x
Reference in New Issue
Block a user