Skip to content

Commit d1c7370

Browse files
committed
apply code review suggestions
1 parent 450bf38 commit d1c7370

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Config\Database;
1818
use PHPUnit\Framework\Attributes\DataProvider;
1919
use PHPUnit\Framework\Attributes\Group;
20-
use ReflectionClass;
2120

2221
/**
2322
* @internal
@@ -239,57 +238,53 @@ public function testGetFieldDataType(): void
239238
}
240239

241240
#[DataProvider('provideNormalizeDefault')]
242-
public function testNormalizeDefault(?string $input, ?string $expected, string $description): void
241+
public function testNormalizeDefault(?string $input, ?string $expected): void
243242
{
244-
$reflection = new ReflectionClass($this->db);
245-
$method = $reflection->getMethod('normalizeDefault');
246-
247-
$result = $method->invoke($this->db, $input);
248-
249-
$this->assertSame($expected, $result, "Failed test: {$description}");
243+
$normalizeDefault = self::getPrivateMethodInvoker($this->db, 'normalizeDefault');
244+
$this->assertSame($expected, $normalizeDefault($input));
250245
}
251246

252247
/**
253-
* @return iterable<array{string|null, string|null, string}>
248+
* @return iterable<string, array{string|null, string|null}>
254249
*/
255250
public static function provideNormalizeDefault(): iterable
256251
{
257252
return [
258-
// [input, expected_output, description]
259-
260253
// Null cases
261-
[null, null, 'null input'],
262-
['(NULL)', null, 'NULL literal wrapped in parentheses'],
263-
['(null)', null, 'null literal lowercase'],
264-
['(Null)', null, 'null literal mixed case'],
265-
['(nULL)', null, 'null literal random case'],
254+
'null input' => [null, null],
255+
'NULL literal wrapped in parentheses' => ['(NULL)', null],
256+
'null literal lowercase' => ['(null)', null],
257+
'null literal mixed case' => ['(Null)', null],
258+
'null literal random case' => ['(nULL)', null],
259+
'null string' => ["('null')", 'null'],
266260

267261
// String literal cases
268-
["('hello')", 'hello', 'simple string'],
269-
["('hello world')", 'hello world', 'string with space'],
270-
["('')", '', 'empty string literal'],
271-
["('can''t')", "can't", 'string with escaped quote'],
272-
["('it''s a ''test''')", "it's a 'test'", 'string with multiple escaped quotes'],
273-
["('line1'+char(10)+'line2')", "line1'+char(10)+'line2", 'concatenated multiline expression'],
262+
'simple string' => ["('hello')", 'hello'],
263+
'empty string' => ['(())', ''],
264+
'string with space' => ["('hello world')", 'hello world'],
265+
'empty string literal' => ["('')", ''],
266+
'string with escaped quote' => ["('can''t')", "can't"],
267+
'string with multiple escaped quotes' => ["('it''s a ''test''')", "it's a 'test'"],
268+
'concatenated multiline expression' => ["('line1'+char(10)+'line2')", "line1'+char(10)+'line2"],
274269

275270
// Numeric cases
276-
['((0))', '0', 'zero with double parentheses'],
277-
['((123))', '123', 'positive integer with double parentheses'],
278-
['((-456))', '-456', 'negative integer with double parentheses'],
279-
['((3.14))', '3.14', 'float with double parentheses'],
271+
'zero with double parentheses' => ['((0))', '0'],
272+
'positive integer with double parentheses' => ['((123))', '123'],
273+
'negative integer with double parentheses' => ['((-456))', '-456'],
274+
'float with double parentheses' => ['((3.14))', '3.14'],
280275

281276
// Function/expression cases
282-
['(getdate())', 'getdate()', 'function call'],
283-
['(newid())', 'newid()', 'newid function'],
284-
['(user_name())', 'user_name()', 'user_name function'],
285-
['(current_timestamp)', 'current_timestamp', 'current_timestamp'],
286-
['((1+1))', '1+1', 'mathematical expression'],
287-
['((100*2))', '100*2', 'multiplication expression'],
277+
'function call' => ['(getdate())', 'getdate()'],
278+
'newid function' => ['(newid())', 'newid()'],
279+
'user_name function' => ['(user_name())', 'user_name()'],
280+
'current_timestamp' => ['(current_timestamp)', 'current_timestamp'],
281+
'mathematical expression' => ['((1+1))', '1+1'],
282+
'multiplication expression' => ['((100*2))', '100*2'],
288283

289284
// Edge cases
290-
["((('nested')))", 'nested', 'multiple nested parentheses'],
291-
['plain_value', 'plain_value', 'value without parentheses'],
292-
['(complex_func(1, 2))', 'complex_func(1, 2)', 'function with parameters'],
285+
'multiple nested parentheses' => ["((('nested')))", 'nested'],
286+
'value without parentheses' => ['plain_value', 'plain_value'],
287+
'function with parameters' => ['(complex_func(1, 2))', 'complex_func(1, 2)'],
293288
];
294289
}
295290
}

utils/phpstan-baseline/deadCode.unreachable.neon

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# total 1 error
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
5+
-
6+
message: '#^Unreachable statement \- code above always terminates\.$#'
7+
count: 1
8+
path: ../../tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php
9+
510
-
611
message: '#^Unreachable statement \- code above always terminates\.$#'
712
count: 1

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2836 errors
1+
# total 2837 errors
22
includes:
33
- argument.type.neon
44
- assign.propertyType.neon

0 commit comments

Comments
 (0)