Skip to content

Commit 42f68a6

Browse files
authored
style: fix code styles from php-cs-fixer v3.82.1 (#9629)
* style: fix code styles from php-cs-fixer v3.82.1 * fix phpstan
1 parent 0121e8d commit 42f68a6

30 files changed

+677
-670
lines changed

tests/system/CommonSingleServiceTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,6 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v
7575
}
7676
}
7777

78-
public function testSingleServiceWithAllParamsSupplied(): void
79-
{
80-
$cache1 = single_service('cache', null, true);
81-
$cache2 = single_service('cache', null, true);
82-
83-
assert($cache1 !== null);
84-
assert($cache2 !== null);
85-
86-
// Assert that even passing true as last param this will
87-
// not create a shared instance.
88-
$this->assertInstanceOf($cache1::class, $cache2);
89-
$this->assertNotSame($cache1, $cache2);
90-
}
91-
92-
public function testSingleServiceWithGibberishGiven(): void
93-
{
94-
$this->assertNull(single_service('foo')); // @phpstan-ignore codeigniter.unknownServiceMethod
95-
$this->assertNull(single_service('bar')); // @phpstan-ignore codeigniter.unknownServiceMethod
96-
$this->assertNull(single_service('baz')); // @phpstan-ignore codeigniter.unknownServiceMethod
97-
$this->assertNull(single_service('caches')); // @phpstan-ignore codeigniter.unknownServiceMethod
98-
$this->assertNull(single_service('timers')); // @phpstan-ignore codeigniter.unknownServiceMethod
99-
}
100-
10178
/**
10279
* @return iterable<string, array{string}>
10380
*/
@@ -137,4 +114,27 @@ public static function provideServiceNames(): iterable
137114

138115
yield from $services;
139116
}
117+
118+
public function testSingleServiceWithAllParamsSupplied(): void
119+
{
120+
$cache1 = single_service('cache', null, true);
121+
$cache2 = single_service('cache', null, true);
122+
123+
assert($cache1 !== null);
124+
assert($cache2 !== null);
125+
126+
// Assert that even passing true as last param this will
127+
// not create a shared instance.
128+
$this->assertInstanceOf($cache1::class, $cache2);
129+
$this->assertNotSame($cache1, $cache2);
130+
}
131+
132+
public function testSingleServiceWithGibberishGiven(): void
133+
{
134+
$this->assertNull(single_service('foo')); // @phpstan-ignore codeigniter.unknownServiceMethod
135+
$this->assertNull(single_service('bar')); // @phpstan-ignore codeigniter.unknownServiceMethod
136+
$this->assertNull(single_service('baz')); // @phpstan-ignore codeigniter.unknownServiceMethod
137+
$this->assertNull(single_service('caches')); // @phpstan-ignore codeigniter.unknownServiceMethod
138+
$this->assertNull(single_service('timers')); // @phpstan-ignore codeigniter.unknownServiceMethod
139+
}
140140
}

tests/system/Config/MimesTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#[Group('Others')]
2525
final class MimesTest extends CIUnitTestCase
2626
{
27+
#[DataProvider('provideGuessExtensionFromType')]
28+
public function testGuessExtensionFromType(?string $expected, string $mime): void
29+
{
30+
$this->assertSame($expected, Mimes::guessExtensionFromType($mime));
31+
}
32+
2733
public static function provideGuessExtensionFromType(): iterable
2834
{
2935
return [
@@ -50,10 +56,10 @@ public static function provideGuessExtensionFromType(): iterable
5056
];
5157
}
5258

53-
#[DataProvider('provideGuessExtensionFromType')]
54-
public function testGuessExtensionFromType(?string $expected, string $mime): void
59+
#[DataProvider('provideGuessTypeFromExtension')]
60+
public function testGuessTypeFromExtension(?string $expected, string $ext): void
5561
{
56-
$this->assertSame($expected, Mimes::guessExtensionFromType($mime));
62+
$this->assertSame($expected, Mimes::guessTypeFromExtension($ext));
5763
}
5864

5965
public static function provideGuessTypeFromExtension(): iterable
@@ -81,10 +87,4 @@ public static function provideGuessTypeFromExtension(): iterable
8187
],
8288
];
8389
}
84-
85-
#[DataProvider('provideGuessTypeFromExtension')]
86-
public function testGuessTypeFromExtension(?string $expected, string $ext): void
87-
{
88-
$this->assertSame($expected, Mimes::guessTypeFromExtension($ext));
89-
}
9090
}

tests/system/Config/ServicesTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function testNewSessionWithNullConfig(): void
263263
$this->assertInstanceOf(Session::class, $actual);
264264
}
265265

266-
#[DataProvider('provideNewSessionInvalid')]
266+
#[DataProvider('provideNewSessionWithInvalidHandler')]
267267
#[PreserveGlobalState(false)]
268268
#[RunInSeparateProcess]
269269
public function testNewSessionWithInvalidHandler(string $driver): void
@@ -277,6 +277,18 @@ public function testNewSessionWithInvalidHandler(string $driver): void
277277
Services::session($config, false);
278278
}
279279

280+
/**
281+
* @return iterable<string, array{0: string}>
282+
*/
283+
public static function provideNewSessionWithInvalidHandler(): iterable
284+
{
285+
yield 'just a string' => ['file'];
286+
287+
yield 'inexistent class' => ['Foo'];
288+
289+
yield 'other class' => [self::class];
290+
}
291+
280292
#[PreserveGlobalState(false)]
281293
#[RunInSeparateProcess]
282294
public function testNewSessionWithInvalidDatabaseHandler(): void
@@ -296,18 +308,6 @@ public function testNewSessionWithInvalidDatabaseHandler(): void
296308
Services::session($config, false);
297309
}
298310

299-
/**
300-
* @return iterable<string, array{0: string}>
301-
*/
302-
public static function provideNewSessionInvalid(): iterable
303-
{
304-
yield 'just a string' => ['file'];
305-
306-
yield 'inexistent class' => ['Foo'];
307-
308-
yield 'other class' => [self::class];
309-
}
310-
311311
#[PreserveGlobalState(false)]
312312
#[RunInSeparateProcess]
313313
public function testCallStatic(): void

tests/system/DataConverter/DataConverterTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ public function testConvertDataFromDB(array $types, array $dbData, array $expect
5050
$this->assertSame($expected, $data);
5151
}
5252

53-
#[DataProvider('provideConvertDataToDB')]
54-
public function testConvertDataToDB(array $types, array $phpData, array $expected): void
55-
{
56-
$converter = $this->createDataConverter($types);
57-
58-
$data = $converter->toDataSource($phpData);
59-
60-
$this->assertSame($expected, $data);
61-
}
62-
6353
public static function provideConvertDataFromDB(): iterable
6454
{
6555
yield from [
@@ -206,6 +196,16 @@ public static function provideConvertDataFromDB(): iterable
206196
];
207197
}
208198

199+
#[DataProvider('provideConvertDataToDB')]
200+
public function testConvertDataToDB(array $types, array $phpData, array $expected): void
201+
{
202+
$converter = $this->createDataConverter($types);
203+
204+
$data = $converter->toDataSource($phpData);
205+
206+
$this->assertSame($expected, $data);
207+
}
208+
209209
public static function provideConvertDataToDB(): iterable
210210
{
211211
yield from [

tests/system/Database/BaseQueryTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ public function testSwapPrefix(): void
107107
$this->assertSame($newSQL, $query->getQuery());
108108
}
109109

110+
/**
111+
* @param mixed $expected
112+
* @param mixed $sql
113+
*/
114+
#[DataProvider('provideIsWriteType')]
115+
public function testIsWriteType($expected, $sql): void
116+
{
117+
$query = new Query($this->db);
118+
119+
$query->setQuery($sql);
120+
$this->assertSame($expected, $query->isWriteType());
121+
}
122+
110123
public static function provideIsWriteType(): iterable
111124
{
112125
return [
@@ -185,19 +198,6 @@ public static function provideIsWriteType(): iterable
185198
];
186199
}
187200

188-
/**
189-
* @param mixed $expected
190-
* @param mixed $sql
191-
*/
192-
#[DataProvider('provideIsWriteType')]
193-
public function testIsWriteType($expected, $sql): void
194-
{
195-
$query = new Query($this->db);
196-
197-
$query->setQuery($sql);
198-
$this->assertSame($expected, $query->isWriteType());
199-
}
200-
201201
public function testSingleBindingOutsideOfArray(): void
202202
{
203203
$query = new Query($this->db);
@@ -579,6 +579,19 @@ public function testSwapPrefixAfterGetQuery(): void
579579
$this->assertSame($expected, $query->getQuery());
580580
}
581581

582+
/**
583+
* @param mixed $expected
584+
* @param mixed $sql
585+
*/
586+
#[DataProvider('provideHighlightQueryKeywords')]
587+
public function testHighlightQueryKeywords($expected, $sql): void
588+
{
589+
$query = new Query($this->db);
590+
$query->setQuery($sql);
591+
592+
$this->assertSame($expected, $query->debugToolbarDisplay());
593+
}
594+
582595
public static function provideHighlightQueryKeywords(): iterable
583596
{
584597
return [
@@ -596,17 +609,4 @@ public static function provideHighlightQueryKeywords(): iterable
596609
],
597610
];
598611
}
599-
600-
/**
601-
* @param mixed $expected
602-
* @param mixed $sql
603-
*/
604-
#[DataProvider('provideHighlightQueryKeywords')]
605-
public function testHighlightQueryKeywords($expected, $sql): void
606-
{
607-
$query = new Query($this->db);
608-
$query->setQuery($sql);
609-
610-
$this->assertSame($expected, $query->debugToolbarDisplay());
611-
}
612612
}

tests/system/Database/Builder/WhenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testWhenNotRunsDefaultCallbackBasedOnCondition(mixed $condition,
206206
/**
207207
* @return array<string, array{0: mixed, 1: bool}>
208208
*/
209-
public static function provideConditionValues(): array
209+
public static function provideConditionValues(): iterable
210210
{
211211
return [
212212
'false' => [false, true], // [condition, expectedDefaultCallbackRuns]

tests/system/Database/Builder/WhereTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,6 @@ public function testWhereInSubQuery(): void
395395
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
396396
}
397397

398-
public static function provideWhereInvalidKeyThrowInvalidArgumentException(): iterable
399-
{
400-
return [
401-
'null' => [null],
402-
'empty string' => [''],
403-
];
404-
}
405-
406398
/**
407399
* @param mixed $key
408400
*/
@@ -415,12 +407,11 @@ public function testWhereInvalidKeyThrowInvalidArgumentException($key): void
415407
$builder->whereIn($key, ['Politician', 'Accountant']);
416408
}
417409

418-
public static function provideWhereInEmptyValuesThrowInvalidArgumentException(): iterable
410+
public static function provideWhereInvalidKeyThrowInvalidArgumentException(): iterable
419411
{
420412
return [
421-
'null' => [null],
422-
'not array' => ['not array'],
423-
'not instanceof \Closure' => [new stdClass()],
413+
'null' => [null],
414+
'empty string' => [''],
424415
];
425416
}
426417

@@ -436,6 +427,15 @@ public function testWhereInEmptyValuesThrowInvalidArgumentException($values): vo
436427
$builder->whereIn('name', $values);
437428
}
438429

430+
public static function provideWhereInEmptyValuesThrowInvalidArgumentException(): iterable
431+
{
432+
return [
433+
'null' => [null],
434+
'not array' => ['not array'],
435+
'not instanceof \Closure' => [new stdClass()],
436+
];
437+
}
438+
439439
public function testWhereNotIn(): void
440440
{
441441
$builder = $this->db->table('jobs');

tests/system/Database/Live/LikeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testLikeCaseInsensitive(): void
7676
$this->assertSame('Developer', $job->name);
7777
}
7878

79-
#[DataProvider('provideMultibyteCharacters')]
79+
#[DataProvider('provideLikeCaseInsensitiveWithMultibyteCharacter')]
8080
public function testLikeCaseInsensitiveWithMultibyteCharacter(string $match, string $result): void
8181
{
8282
$wai = $this->db->table('without_auto_increment')->like('value', $match, 'both', null, true)->get();
@@ -88,7 +88,7 @@ public function testLikeCaseInsensitiveWithMultibyteCharacter(string $match, str
8888
/**
8989
* @return iterable<string, array{0: string, 1: string}>
9090
*/
91-
public static function provideMultibyteCharacters(): iterable
91+
public static function provideLikeCaseInsensitiveWithMultibyteCharacter(): iterable
9292
{
9393
yield from [
9494
'polish' => ['ŁĄ', 'multibyte characters pl'],

tests/system/Email/EmailTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ public function testEmailValidation(): void
3939
$this->assertStringContainsString('Invalid email address: "invalid"', $email->printDebugger());
4040
}
4141

42-
public static function provideEmailSendWithClearance(): iterable
43-
{
44-
return [
45-
'autoclear' => [true],
46-
'not autoclear' => [false],
47-
];
48-
}
49-
5042
/**
5143
* @param bool $autoClear
5244
*/
@@ -64,6 +56,14 @@ public function testEmailSendWithClearance($autoClear): void
6456
}
6557
}
6658

59+
public static function provideEmailSendWithClearance(): iterable
60+
{
61+
return [
62+
'autoclear' => [true],
63+
'not autoclear' => [false],
64+
];
65+
}
66+
6767
public function testEmailSendStoresArchive(): void
6868
{
6969
$email = $this->createMockEmail();

0 commit comments

Comments
 (0)