Skip to content

Commit 617a6de

Browse files
committed
! some more depreciation notices fixed
1 parent d46ee7c commit 617a6de

File tree

8 files changed

+78
-70
lines changed

8 files changed

+78
-70
lines changed

.github/ElkTestingMysql.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public function __construct($db, $db_prefix)
3232
global $db_prefix;
3333

3434
// We are installing, of course we want to do any remove on these
35-
$this->_reservedTables = array();
35+
$this->_reservedTables = [];
3636

3737
foreach ($this->_reservedTables as $k => $table_name)
3838
{
3939
$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
4040
}
4141

4242
// let's be sure.
43-
$this->_package_log = array();
43+
$this->_package_log = [];
4444

4545
// This executes queries and things
4646
$this->_db = $db;

.github/ElkTestingPsql.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
*
1414
*/
1515

16+
use ElkArte\Database\Postgresql\Connection;
17+
use ElkArte\Database\Postgresql\Table;
18+
1619
/**
1720
* Sets up a Database_PostgreSQL object
1821
*/
19-
class DbTable_PostgreSQL_Install extends \ElkArte\Database\Postgresql\Table
22+
class DbTable_PostgreSQL_Install extends Table
2023
{
2124
public static $_tbl_inst = null;
2225

@@ -30,15 +33,15 @@ public function __construct($db, $db_prefix)
3033
global $db_prefix;
3134

3235
// We are doing install, of course we want to do any remove on these
33-
$this->_reservedTables = array();
36+
$this->_reservedTables = [];
3437

3538
foreach ($this->_reservedTables as $k => $table_name)
3639
{
3740
$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
3841
}
3942

4043
// let's be sure.
41-
$this->_package_log = array();
44+
$this->_package_log = [];
4245

4346
// This executes queries and things
4447
$this->_db = $db;
@@ -71,8 +74,7 @@ class Elk_Testing_psql extends ElkTestingSetup
7174
{
7275
public function init()
7376
{
74-
global $db_name, $db_prefix, $db_type, $boardurl, $db_server, $db_user, $db_passwd;
75-
global $modSettings;
77+
global $db_name, $db_prefix, $db_type, $boardurl, $db_server, $db_user, $db_passwd, $modSettings;
7678

7779
$boardurl = $this->_boardurl = 'http://127.0.0.1';
7880
$db_server = $this->_db_server = '127.0.0.1';
@@ -96,7 +98,7 @@ public function init()
9698
try
9799
{
98100
// Start the database interface
99-
$this->_db = \ElkArte\Database\Postgresql\Connection::initiate($this->_db_server, $this->_db_name, $this->_db_user, $this->_db_passwd, $this->_db_prefix);
101+
$this->_db = Connection::initiate($this->_db_server, $this->_db_name, $this->_db_user, $this->_db_passwd, $this->_db_prefix);
100102
$this->_db_table = DbTable_PostgreSQL_Install::db_table($this->_db, $this->_db_prefix);
101103
}
102104
catch (\Exception $e)
@@ -118,7 +120,6 @@ public function init()
118120
if (empty($result))
119121
return 1;
120122

121-
122123
// Prepare Settings.php, add a member, set time
123124
$this->prepare();
124125
return 0;

.github/SetupDbUtil.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
global $txt;
1717

18-
define('BOARDDIR', dirname(__FILE__) . '/..');
18+
define('BOARDDIR', __DIR__ . '/..');
1919
define('CACHEDIR', BOARDDIR . '/cache');
2020
define('ELK', '1');
2121

@@ -62,7 +62,7 @@ class ElkTestingSetup
6262
*/
6363
public function run_queries()
6464
{
65-
$exists = array();
65+
$exists = [];
6666
$success = true;
6767
foreach ($this->_queries['tables'] as $table_method)
6868
{
@@ -88,7 +88,7 @@ public function run_queries()
8888
{
8989
$table_name = substr($insert_method, 6);
9090

91-
if (in_array($table_name, $exists))
91+
if (in_array($table_name, $exists, true))
9292
{
9393
continue;
9494
}
@@ -135,14 +135,14 @@ public function load_queries($sql_file)
135135
$replaces['{$' . $key . '}'] = $value;
136136
}
137137
}
138-
$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
138+
$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], ['\\\\n' => '\\n']);
139139

140140
$this->_db->skip_next_error();
141141
$db_wrapper = new DbWrapper($this->_db, $replaces);
142142
$db_table_wrapper = new DbTableWrapper($this->_db_table);
143143

144144
$current_statement = '';
145-
$exists = array();
145+
$exists = [];
146146

147147
require_once($sql_file);
148148

@@ -162,7 +162,7 @@ public function load_queries($sql_file)
162162

163163
$this->_queries['others'] = array_filter($methods, function ($method)
164164
{
165-
return substr($method, 0, 2) !== '__' && strpos($method, 'insert_') !== 0 && strpos($method, 'table_') !== 0;
165+
return strpos($method, '__') !== 0 && strpos($method, 'insert_') !== 0 && strpos($method, 'table_') !== 0;
166166
});
167167
}
168168

@@ -270,25 +270,25 @@ public function update()
270270

271271
$db->insert('', '
272272
{db_prefix}members',
273-
array(
273+
[
274274
'member_name' => 'string-25', 'real_name' => 'string-25', 'passwd' => 'string', 'email_address' => 'string',
275275
'id_group' => 'int', 'posts' => 'int', 'date_registered' => 'int', 'hide_email' => 'int',
276276
'password_salt' => 'string', 'lngfile' => 'string', 'avatar' => 'string',
277277
'member_ip' => 'string', 'member_ip2' => 'string', 'buddy_list' => 'string', 'pm_ignore_list' => 'string',
278278
'message_labels' => 'string', 'website_title' => 'string', 'website_url' => 'string',
279279
'signature' => 'string', 'usertitle' => 'string', 'secret_question' => 'string',
280280
'additional_groups' => 'string', 'ignore_boards' => 'string',
281-
),
282-
array(
281+
],
282+
[
283283
'test_admin', 'test_admin', $passwd, 'email@testadmin.tld',
284284
1, 0, time(), 0,
285285
substr(md5(mt_rand()), 0, 4), '', '',
286286
'123.123.123.123', '123.123.123.123', '', '',
287287
'', '', '',
288288
'', '', '',
289289
'', '',
290-
),
291-
array('id_member')
290+
],
291+
['id_member']
292292
);
293293

294294
// The old Etc/GMT value is discouraged and does not work in some installs
@@ -298,13 +298,13 @@ public function update()
298298
{
299299
$db->insert('',
300300
$db_prefix . 'settings',
301-
array(
301+
[
302302
'variable' => 'string-255', 'value' => 'string-65534',
303-
),
304-
array(
303+
],
304+
[
305305
'default_timezone', $timezone_id,
306-
),
307-
array('variable')
306+
],
307+
['variable']
308308
);
309309
}
310310
}
@@ -314,7 +314,7 @@ class DbWrapper
314314
{
315315
protected $db = null;
316316
protected $count_mode = false;
317-
protected $replaces = array();
317+
protected $replaces = [];
318318

319319
public function __construct($db, $replaces)
320320
{
@@ -324,7 +324,7 @@ public function __construct($db, $replaces)
324324

325325
public function __call($name, $args)
326326
{
327-
return call_user_func_array(array($this->db, $name), $args);
327+
return call_user_func_array([$this->db, $name], $args);
328328
}
329329

330330
public function insert()
@@ -344,9 +344,9 @@ public function insert()
344344
}
345345
}
346346

347-
call_user_func_array(array($this->db, 'insert'), $args);
347+
call_user_func_array([$this->db, 'insert'], $args);
348348

349-
return $this->db->affected_rows();
349+
//return $this->db->affected_rows();
350350
}
351351

352352
public function countMode($on = true)

.github/SetupPgsql.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*/
1515

16-
define('TESTDIR', dirname(__FILE__));
16+
define('TESTDIR', __DIR__);
1717

1818
require_once(TESTDIR . '/SetupDbUtil.php');
1919
require_once(TESTDIR . '/ElkTestingPsql.php');

sources/ElkArte/Database/Postgresql/Result.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function affected_rows()
3636
}
3737

3838
$resource = $this->result ?? $this->details->lastResult;
39-
if ($resource instanceof \PgSQL\Result)
39+
if (is_resource($resource) || $resource instanceof \PgSQL\Result)
4040
{
4141
return pg_affected_rows($resource);
4242
}

tests/sources/subs/DbAbstraction.class.Test.php

+25-22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
class TestDbAbstraction extends TestCase
66
{
77
protected $backupGlobalsExcludeList = ['user_info'];
8+
public $_dummy_db;
9+
public $tests;
10+
811
/**
912
* Prepare what is necessary to use in these tests.
1013
*
@@ -14,40 +17,40 @@ protected function setUp(): void
1417
{
1518
$this->_dummy_db = database();
1619

17-
$this->tests = array(
18-
array(
20+
$this->tests = [
21+
[
1922
'string_test' => '{string_case_sensitive:a_string}',
20-
'params_test' => array('a_string' => 'a_string'),
21-
'results' => array(
23+
'params_test' => ['a_string' => 'a_string'],
24+
'results' => [
2225
'MySQL' => 'BINARY \'a_string\'',
2326
'PostgreSQL' => '\'a_string\'',
24-
)
25-
),
26-
array(
27+
]
28+
],
29+
[
2730
'string_test' => '{string_case_insensitive:a_string}',
28-
'params_test' => array('a_string' => 'a_string'),
29-
'results' => array(
31+
'params_test' => ['a_string' => 'a_string'],
32+
'results' => [
3033
'MySQL' => '\'a_string\'',
3134
'PostgreSQL' => 'LOWER(\'a_string\')',
32-
)
33-
),
34-
array(
35+
]
36+
],
37+
[
3538
'string_test' => '{array_string_case_insensitive:a_string}',
36-
'params_test' => array('a_string' => array('a_string', 'another_string')),
37-
'results' => array(
39+
'params_test' => ['a_string' => ['a_string', 'another_string']],
40+
'results' => [
3841
'MySQL' => '\'a_string\', \'another_string\'',
3942
'PostgreSQL' => 'LOWER(\'a_string\'), LOWER(\'another_string\')',
40-
)
41-
),
42-
array(
43+
]
44+
],
45+
[
4346
'string_test' => '{column_case_insensitive:a_string}',
44-
'params_test' => array('a_string' => array('a_string', 'another_string')),
45-
'results' => array(
47+
'params_test' => ['a_string' => ['a_string', 'another_string']],
48+
'results' => [
4649
'MySQL' => 'a_string',
4750
'PostgreSQL' => 'LOWER(a_string)',
48-
)
49-
),
50-
);
51+
]
52+
],
53+
];
5154
}
5255

5356
public function testCallback()

tests/sources/subs/Emailpost.subs.Basic.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
class TestEmailpost extends TestCase
66
{
77
protected $backupGlobalsExcludeList = ['user_info'];
8+
public $bbcTestCases;
9+
810
/**
911
* Prepare what is necessary to use in these tests.
1012
*
@@ -14,31 +16,31 @@ protected function setUp(): void
1416
{
1517
require_once(SUBSDIR . '/Emailpost.subs.php');
1618

17-
$this->bbcTestCases = array(
18-
array(
19+
$this->bbcTestCases = [
20+
[
1921
'Test bold',
2022
'**bold**',
2123
'[b]bold[/b]',
22-
),
23-
array(
24+
],
25+
[
2426
'Named links',
2527
'[ElkArte](http://www.elkarte.net/)',
2628
'[url=http://www.elkarte.net/]ElkArte[/url]',
27-
),
28-
array(
29+
],
30+
[
2931
'URL link',
3032
'[http://www.elkarte.net/](http://www.elkarte.net/)',
3133
'[url=http://www.elkarte.net/]http://www.elkarte.net/[/url]',
32-
),
34+
],
3335
// This test is here only to remind that the Markdown library doesn't support nested lists
34-
array(
36+
[
3537
'Lists',
3638
'* item
3739
* sub item
3840
*item',
3941
'[list][li]item[/li][li]sub item*item[/li][/list]',
40-
),
41-
);
42+
],
43+
];
4244
}
4345

4446
/**

tests/sources/subs/Like.subs.Test.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
class TestLikes extends TestCase
1313
{
1414
protected $backupGlobalsExcludeList = ['user_info'];
15+
public $id_topic;
16+
1517
/**
1618
* Prepare some test data, to use in these tests.
1719
*
@@ -25,28 +27,28 @@ protected function setUp(): void
2527
require_once(SUBSDIR . '/Post.subs.php');
2628

2729
// post variables
28-
$msgOptions = array(
30+
$msgOptions = [
2931
'id' => 0,
3032
'subject' => 'A New Topic',
3133
'smileys_enabled' => true,
3234
'body' => 'Something for us to like, like bacon on a burger',
33-
'attachments' => array(),
35+
'attachments' => [],
3436
'approved' => 1
35-
);
37+
];
3638

37-
$topicOptions = array(
39+
$topicOptions = [
3840
'id' => 0,
3941
'board' => 1,
4042
'mark_as_read' => false
41-
);
43+
];
4244

43-
$posterOptions = array(
45+
$posterOptions = [
4446
'id' => 1,
4547
'name' => 'test',
4648
'email' => 'noemail@test.tes',
4749
'update_post_count' => false,
4850
'ip' => long2ip(rand(0, 2147483647))
49-
);
51+
];
5052

5153
// Attempt to make the new topic.
5254
createPost($msgOptions, $topicOptions, $posterOptions);

0 commit comments

Comments
 (0)