Skip to content

Commit c1ffc3c

Browse files
committed
[ticket/17176] Resolve deprecation notices
PHPBB3-17176
1 parent c1b6d66 commit c1ffc3c

18 files changed

+39
-41
lines changed

config/config.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(array $config)
3939
*
4040
* @return \ArrayIterator An iterator over all config data
4141
*/
42-
public function getIterator()
42+
public function getIterator(): \ArrayIterator
4343
{
4444
return new \ArrayIterator($this->config);
4545
}
@@ -99,7 +99,7 @@ public function offsetUnset($key)
9999
*
100100
* @return int Number of config options
101101
*/
102-
public function count()
102+
public function count(): int
103103
{
104104
return count($this->config);
105105
}

controller/resolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function getArguments(Request $request, $controller)
160160
$arguments[] = $attributes[$param->name];
161161
}
162162
}
163-
else if ($param->getClass() && $param->getClass()->isInstance($request))
163+
else if ($param->getType() && $param->getType() instanceof $request)
164164
{
165165
$arguments[] = $request;
166166
}

db/migrator.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ class migrator
9191
*
9292
* 'effectively_installed' set and set to true if the migration was effectively_installed
9393
*
94-
* @var array|false
94+
* @var array
9595
*/
96-
protected $last_run_migration = false;
96+
protected $last_run_migration = [];
9797

9898
/**
9999
* The output handler. A null handler is configured by default.
@@ -193,9 +193,9 @@ public function load_migration_state()
193193
* The array contains 'name', 'class' and 'state'. 'effectively_installed' is set
194194
* and set to true if the last migration was effectively_installed.
195195
*
196-
* @return array|false Last run migration information or false if no migration has been run yet
196+
* @return array Last run migration information or false if no migration has been run yet
197197
*/
198-
public function get_last_run_migration()
198+
public function get_last_run_migration(): array
199199
{
200200
return $this->last_run_migration;
201201
}
@@ -630,7 +630,7 @@ protected function try_revert($name)
630630
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
631631
$this->db->sql_query($sql);
632632

633-
$this->last_run_migration = false;
633+
$this->last_run_migration = [];
634634
unset($this->migration_state[$name]);
635635

636636
$this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);

di/extension/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getAlias(): string
7373
*/
7474
protected function convert_30_acm_type($acm_type)
7575
{
76-
if (preg_match('#^[a-z]+$#', $acm_type))
76+
if (preg_match('#^[a-z]+$#', $acm_type ?? ''))
7777
{
7878
return 'phpbb\\cache\\driver\\' . $acm_type;
7979
}

di/ordered_service_collection.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(ContainerInterface $container)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getIterator()
49+
public function getIterator(): \Iterator
5050
{
5151
if (!$this->is_ordered)
5252
{
@@ -59,27 +59,27 @@ public function getIterator()
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public function offsetExists($index)
62+
public function offsetExists($key): bool
6363
{
6464
if (!$this->is_ordered)
6565
{
6666
$this->sort_services();
6767
}
6868

69-
return parent::offsetExists($index);
69+
return parent::offsetExists($key);
7070
}
7171

7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function offsetGet($index)
75+
public function offsetGet($key): mixed
7676
{
7777
if (!$this->is_ordered)
7878
{
7979
$this->sort_services();
8080
}
8181

82-
return parent::offsetGet($index);
82+
return parent::offsetGet($key);
8383
}
8484

8585
/**

di/service_collection.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public function __construct(ContainerInterface $container)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getIterator()
49+
public function getIterator(): \Iterator
5050
{
5151
return new service_collection_iterator($this);
5252
}
5353

5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function offsetGet($index)
57+
public function offsetGet($key): mixed
5858
{
59-
return $this->container->get($index);
59+
return $this->container->get($key);
6060
}
6161

6262
/**

di/service_collection_iterator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(service_collection $collection, $flags = 0)
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function current()
42+
public function current(): mixed
4343
{
4444
return $this->collection->offsetGet($this->key());
4545
}

event/recursive_event_filter_iterator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(\RecursiveIterator $iterator, $root_path)
3939
*
4040
* @return recursive_event_filter_iterator
4141
*/
42-
public function getChildren()
42+
public function getChildren(): ?\RecursiveFilterIterator
4343
{
4444
$inner_iterator = $this->getInnerIterator();
4545
assert($inner_iterator instanceof \RecursiveIterator);
@@ -49,7 +49,7 @@ public function getChildren()
4949
/**
5050
* {@inheritDoc}
5151
*/
52-
public function accept()
52+
public function accept(): bool
5353
{
5454
$relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $this->current());
5555
$filename = $this->current()->getFilename();

files/filespec.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function set_upload_ary($upload_ary)
137137
$this->mimetype = $upload_ary['type'];
138138

139139
// Opera adds the name to the mime type
140-
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
140+
$this->mimetype = ($this->mimetype && str_contains($this->mimetype, '; name')) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
141141

142142
if (!$this->mimetype)
143143
{

files/filespec_storage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function set_upload_ary($upload_ary)
117117
$this->mimetype = $upload_ary['type'];
118118

119119
// Opera adds the name to the mime type
120-
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
120+
$this->mimetype = ($this->mimetype && str_contains($this->mimetype, '; name')) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
121121

122122
if (!$this->mimetype)
123123
{

filesystem/filesystem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ protected function phpbb_is_writable($file)
606606
protected function phpbb_own_realpath($path)
607607
{
608608
// Replace all directory separators with '/'
609-
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
609+
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path ?: '');
610610

611611
$is_absolute_path = false;
612612
$path_prefix = '';

finder/finder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct(?service $cache, bool $use_cache, string $phpbb_root
7777
);
7878
$this->extensions = array();
7979

80-
$this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false;
80+
$this->cached_queries = $this->cache ? ($this->cache->get($this->cache_name) ?: []) : [];
8181
}
8282

8383
/**

notification/type/base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function set_initial_data($data = array())
118118
{
119119
// The row from the database (unless this is a new notification we're going to add)
120120
$this->data = $data;
121-
$this->data['notification_data'] = (isset($this->data['notification_data'])) ? unserialize($this->data['notification_data']) : array();
121+
$this->data['notification_data'] = !empty($this->data['notification_data']) ? unserialize($this->data['notification_data']) : [];
122122
}
123123

124124
/**

profilefields/type/type_date.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function get_profile_field($profile_row)
150150
*/
151151
public function validate_profile_field(&$field_value, $field_data)
152152
{
153-
$field_validate = explode('-', $field_value);
153+
$field_validate = explode('-', $field_value ?: '');
154154

155155
$day = (isset($field_validate[0])) ? (int) $field_validate[0] : 0;
156156
$month = (isset($field_validate[1])) ? (int) $field_validate[1] : 0;
@@ -184,7 +184,7 @@ public function validate_profile_field(&$field_value, $field_data)
184184
*/
185185
public function get_profile_value($field_value, $field_data)
186186
{
187-
$date = explode('-', $field_value);
187+
$date = explode('-', $field_value ?: '');
188188
$day = (isset($date[0])) ? (int) $date[0] : 0;
189189
$month = (isset($date[1])) ? (int) $date[1] : 0;
190190
$year = (isset($date[2])) ? (int) $date[2] : 0;

profilefields/type/type_int.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function get_profile_field($profile_row)
120120
*/
121121
public function validate_profile_field(&$field_value, $field_data)
122122
{
123-
if (trim($field_value) === '' && !$field_data['field_required'])
123+
if (trim($field_value ?: '') === '' && !$field_data['field_required'])
124124
{
125125
return false;
126126
}

profilefields/type/type_string_common.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ public function get_default_field_value($field_data)
6363
*/
6464
public function validate_string_profile_field($field_type, &$field_value, $field_data)
6565
{
66-
if (trim($field_value) === '' && !$field_data['field_required'])
66+
if (trim($field_value ?? '') === '')
6767
{
68-
return false;
69-
}
70-
else if (trim($field_value) === '' && $field_data['field_required'])
71-
{
72-
return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name']));
68+
return $field_data['field_required'] ? $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])) : false;
7369
}
7470

7571
if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen'])

request/deactivated_super_global.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace phpbb\request;
1515

16+
use ReturnTypeWillChange;
17+
1618
/**
1719
* Replacement for a superglobal (like $_GET or $_POST) which calls
1820
* trigger_error on all operations but isset, overloads the [] operator with SPL.
@@ -74,25 +76,25 @@ private function error()
7476
*
7577
* @return bool Whether the key on the super global exists.
7678
*/
77-
public function offsetExists($offset)
79+
public function offsetExists($offset): bool
7880
{
7981
return $this->request->is_set($offset, $this->super_global);
8082
}
8183

8284
/**#@+
8385
* Part of the \ArrayAccess implementation, will always result in a FATAL error.
8486
*/
85-
public function offsetGet($offset)
87+
public function offsetGet($offset): mixed
8688
{
8789
$this->error();
8890
}
8991

90-
public function offsetSet($offset, $value)
92+
public function offsetSet($offset, $value): void
9193
{
9294
$this->error();
9395
}
9496

95-
public function offsetUnset($offset)
97+
public function offsetUnset($offset): void
9698
{
9799
$this->error();
98100
}
@@ -103,7 +105,7 @@ public function offsetUnset($offset)
103105
* @return void
104106
* @psalm-suppress InvalidReturnType
105107
*/
106-
public function count()
108+
public function count(): int
107109
{
108110
$this->error();
109111
}
@@ -113,7 +115,7 @@ public function count()
113115
* @return void
114116
* @psalm-suppress InvalidReturnType
115117
*/
116-
public function getIterator()
118+
#[ReturnTypeWillChange] public function getIterator(): void
117119
{
118120
$this->error();
119121
}

session.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static function extract_current_page($root_path)
4747

4848
// First of all, get the request uri...
4949
$script_name = $request->escape($symfony_request->getScriptName(), true);
50-
$args = $request->escape(explode('&', $symfony_request->getQueryString()), true);
50+
$args = $request->escape(explode('&', $symfony_request->getQueryString() ?? ''), true);
5151

5252
// 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...
5353
if (!$script_name)

0 commit comments

Comments
 (0)