Skip to content

Commit 92d3e57

Browse files
committed
Fix deprecations
1 parent c002a38 commit 92d3e57

File tree

7 files changed

+44
-26
lines changed

7 files changed

+44
-26
lines changed

helper/validator.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(language $language)
4141
*/
4242
public function validate_num_authors($value)
4343
{
44-
if ($value > 0 && $value <= 20 && ctype_digit($value))
44+
if ((int) $value > 0 && (int) $value <= 20 && ctype_digit($value))
4545
{
4646
return $value;
4747
}
@@ -58,6 +58,8 @@ public function validate_num_authors($value)
5858
*/
5959
public function validate_extension_name($value)
6060
{
61+
$value = (string) $value;
62+
6163
if (preg_match('#^[a-z][a-z0-9]*$#', $value))
6264
{
6365
return $value;
@@ -75,6 +77,8 @@ public function validate_extension_name($value)
7577
*/
7678
public function validate_extension_display_name($value)
7779
{
80+
$value = (string) $value;
81+
7882
if ((string) $value !== '' && strpos($value, '&quot;') === false)
7983
{
8084
return htmlspecialchars_decode($value, ENT_NOQUOTES);
@@ -92,6 +96,8 @@ public function validate_extension_display_name($value)
9296
*/
9397
public function validate_extension_time($value)
9498
{
99+
$value = (string) $value;
100+
95101
if (preg_match('#^\d{4}-\d{2}-\d{2}$#', $value))
96102
{
97103
return $value;
@@ -109,6 +115,8 @@ public function validate_extension_time($value)
109115
*/
110116
public function validate_extension_version($value)
111117
{
118+
$value = (string) $value;
119+
112120
if (preg_match('#^\d+(\.\d){1,3}(-(((?:a|b|RC|pl)\d+)|dev))?$#', $value))
113121
{
114122
return $value;
@@ -126,6 +134,8 @@ public function validate_extension_version($value)
126134
*/
127135
public function validate_vendor_name($value)
128136
{
137+
$value = (string) $value;
138+
129139
if ($value !== 'core' && preg_match('#^[a-z][a-z0-9]*$#', $value))
130140
{
131141
return $value;
@@ -143,7 +153,9 @@ public function validate_vendor_name($value)
143153
*/
144154
public function validate_extension_homepage($value)
145155
{
146-
if ((string) $value !== '' && filter_var($value, FILTER_VALIDATE_URL) === false)
156+
$value = (string) $value;
157+
158+
if ( $value !== '' && filter_var($value, FILTER_VALIDATE_URL) === false)
147159
{
148160
throw new runtime_exception($this->language->lang('SKELETON_INVALID_EXTENSION_URL'));
149161
}
@@ -160,7 +172,9 @@ public function validate_extension_homepage($value)
160172
*/
161173
public function validate_author_homepage($value)
162174
{
163-
if ((string) $value !== '' && filter_var($value, FILTER_VALIDATE_URL) === false)
175+
$value = (string) $value;
176+
177+
if ($value !== '' && filter_var($value, FILTER_VALIDATE_URL) === false)
164178
{
165179
throw new runtime_exception($this->language->lang('SKELETON_INVALID_AUTHOR_URL'));
166180
}
@@ -177,7 +191,9 @@ public function validate_author_homepage($value)
177191
*/
178192
public function validate_author_email($value)
179193
{
180-
if ((string) $value !== '' && filter_var($value, FILTER_VALIDATE_EMAIL) === false)
194+
$value = (string) $value;
195+
196+
if ($value !== '' && filter_var($value, FILTER_VALIDATE_EMAIL) === false)
181197
{
182198
throw new runtime_exception($this->language->lang('SKELETON_INVALID_AUTHOR_EMAIL'));
183199
}
@@ -194,6 +210,8 @@ public function validate_author_email($value)
194210
*/
195211
public function validate_phpbb_version_min($value)
196212
{
213+
$value = (string) $value;
214+
197215
if ($this->check_version($value))
198216
{
199217
return $value;
@@ -212,6 +230,8 @@ public function validate_phpbb_version_min($value)
212230
*/
213231
public function validate_phpbb_version_max($value)
214232
{
233+
$value = (string) $value;
234+
215235
if ($this->check_version($value))
216236
{
217237
return $value;
@@ -230,6 +250,8 @@ public function validate_phpbb_version_max($value)
230250
*/
231251
public function validate_php_version($value)
232252
{
253+
$value = (string) $value;
254+
233255
if ($this->check_version($value))
234256
{
235257
return $value;

phpunit.xml.dist

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,12 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
backupGlobals="true"
5-
backupStaticAttributes="false"
65
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
106
processIsolation="false"
117
stopOnFailure="false"
128
cacheResult="false"
139
bootstrap="../../../../tests/bootstrap.php"
14-
>
15-
<coverage>
16-
<include>
17-
<directory suffix=".php">./</directory>
18-
</include>
19-
<exclude>
20-
<directory suffix=".php">./language/</directory>
21-
<directory suffix=".php">./migrations/</directory>
22-
<directory suffix=".php">./tests/</directory>
23-
</exclude>
24-
</coverage>
10+
backupStaticProperties="false">
2511
<testsuites>
2612
<testsuite name="Extension Test Suite">
2713
<directory suffix="_test.php">./tests</directory>
@@ -31,4 +17,14 @@
3117
<directory suffix="_test.php">./tests/functional/</directory>
3218
</testsuite>
3319
</testsuites>
20+
<source>
21+
<include>
22+
<directory suffix=".php">./</directory>
23+
</include>
24+
<exclude>
25+
<directory suffix=".php">./language/</directory>
26+
<directory suffix=".php">./migrations/</directory>
27+
<directory suffix=".php">./tests/</directory>
28+
</exclude>
29+
</source>
3430
</phpunit>

tests/console/create_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function test_create()
204204
$this->assertStringContainsString('EXTENSION_CLI_SKELETON_SUCCESS', $command_tester->getDisplay());
205205
}
206206

207-
public function invalid_data(): array
207+
public static function invalid_data(): array
208208
{
209209
return [
210210
[['SKELETON_QUESTION_VENDOR_NAME' => 'foo bar']],

tests/controller/main_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function get_controller(MockObject|packager $packager): main
114114
);
115115
}
116116

117-
public function handle_data(): array
117+
public static function handle_data(): array
118118
{
119119
return [
120120
[200, '@phpbb_skeleton/skeleton_body.html'],

tests/helper/packager_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function test_get_language_version_data_returns_expected($phpbb_version,
155155
$this->assertSame($expected['indent']['object'], $result['indent']['object']);
156156
}
157157

158-
public function provide_language_version_data()
158+
public static function provide_language_version_data()
159159
{
160160
return [
161161
'3.1 version' => [

tests/helper/validator_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function setUp(): void
3535
);
3636
}
3737

38-
public function valid_data(): array
38+
public static function valid_data(): array
3939
{
4040
return [
4141
['num_authors', '1'],
@@ -126,7 +126,7 @@ public function test_validator_valid(string $validator, string|null $value)
126126
$this->assertEquals($value, call_user_func([$this->validator, "validate_$validator"], $value));
127127
}
128128

129-
public function invalid_data(): array
129+
public static function invalid_data(): array
130130
{
131131
return [
132132
['num_authors', '21', 'SKELETON_INVALID_NUM_AUTHORS'],

tests/template/template_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function setup_engine(array $new_config = array(), string $template_pa
100100
$this->template->set_custom_style('tests', $this->template_path);
101101
}
102102

103-
public function data_template_version_check(): array
103+
public static function data_template_version_check(): array
104104
{
105105
return [
106106
[
@@ -142,7 +142,7 @@ public function data_template_version_check(): array
142142
[
143143
'skeleton_version_compare.html',
144144
[
145-
'ver1' => null,
145+
'ver1' => '',
146146
'ver2' => '3.3.0',
147147
'operator' => '<',
148148
],

0 commit comments

Comments
 (0)