Skip to content

Commit fd2a46c

Browse files
committed
WIP: Update test and cs-fix
1 parent 894e0a6 commit fd2a46c

File tree

13 files changed

+78
-86
lines changed

13 files changed

+78
-86
lines changed

phpstan-baseline.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12235,12 +12235,6 @@
1223512235
'count' => 1,
1223612236
'path' => __DIR__ . '/tests/system/CommonFunctionsTest.php',
1223712237
];
12238-
$ignoreErrors[] = [
12239-
// identifier: missingType.iterableValue
12240-
'message' => '#^Method CodeIgniter\\\\CommonFunctionsTest\\:\\:provideCleanPathActuallyCleaningThePaths\\(\\) return type has no value type specified in iterable type iterable\\.$#',
12241-
'count' => 1,
12242-
'path' => __DIR__ . '/tests/system/CommonFunctionsTest.php',
12243-
];
1224412238
$ignoreErrors[] = [
1224512239
// identifier: codeigniter.modelArgumentType
1224612240
'message' => '#^Parameter \\#1 \\$name of function model expects a valid class string, \'JobModel\' given\\.$#',
@@ -13071,15 +13065,15 @@
1307113065
];
1307213066
$ignoreErrors[] = [
1307313067
// identifier: property.notFound
13074-
'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$numberNative\\.$#',
13068+
'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$foundRows\\.$#',
1307513069
'count' => 2,
13076-
'path' => __DIR__ . '/tests/system/Database/Live/MySQLi/NumberNativeTest.php',
13070+
'path' => __DIR__ . '/tests/system/Database/Live/MySQLi/FoundRowsTest.php',
1307713071
];
1307813072
$ignoreErrors[] = [
1307913073
// identifier: property.notFound
13080-
'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$foundRows\\.$#',
13074+
'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$numberNative\\.$#',
1308113075
'count' => 2,
13082-
'path' => __DIR__ . '/tests/system/Database/Live/MySQLi/FoundRowsTest.php',
13076+
'path' => __DIR__ . '/tests/system/Database/Live/MySQLi/NumberNativeTest.php',
1308313077
];
1308413078
$ignoreErrors[] = [
1308513079
// identifier: missingType.property

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,7 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa
422422

423423
$newPaths = [];
424424

425-
$namespacePaths = array_map(static function (array $paths) {
426-
return array_map(function(string $path) {
427-
return normalize_path($path);
428-
}, $paths);
429-
}, $namespacePaths);
425+
$namespacePaths = array_map(static fn (array $paths) => array_map(static fn (string $path) => normalize_path($path), $paths), $namespacePaths);
430426

431427
foreach ($namespacePaths as $namespace => $srcPaths) {
432428
$add = false;

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static function promptByMultipleKeys(string $text, array $options): array
324324
$optsKey[] = $key;
325325
}
326326
$extraOutput = '[' . $extraOutputDefault . ', ' . implode(', ', $optsKey) . ']';
327-
$extraOutput = 'You can specify multiple values separated by commas.' . "/n" . $extraOutput;
327+
$extraOutput = 'You can specify multiple values separated by commas./n' . $extraOutput;
328328
}
329329

330330
CLI::write($text);
@@ -1098,7 +1098,7 @@ public static function table(array $tbody, array $thead = [])
10981098
}
10991099

11001100
// Set the columns borders
1101-
$table .= '| ' . implode(' | ', $tableRows[$row]) . ' |' . "\n";
1101+
$table .= '| ' . implode(' | ', $tableRows[$row]) . " |\n";
11021102

11031103
// Set the thead and table borders-bottom
11041104
if (($row === 0 && $thead !== []) || ($row + 1 === $totalRows)) {

system/Commands/Translation/LocalizationFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private function findTranslationsInFile($file): array
200200
}
201201

202202
foreach ($matches[1] as $phraseKey) {
203-
$phraseKeys = explode('.', $phraseKey);
203+
$phraseKeys = explode('.', $phraseKey);
204204
$realPathFile = normalize_path($file->getRealPath());
205205

206206
// Language key not have Filename or Lang key

system/Commands/Utilities/ConfigCheck.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use CodeIgniter\CLI\CLI;
1919
use CodeIgniter\Config\BaseConfig;
2020
use Config\Optimize;
21-
use Ergebnis\Json\Json;
2221
use Kint\Kint;
2322

2423
/**

system/Helpers/filesystem_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function get_file_info(string $file, $returnedValues = ['name', 'server_path', '
306306
{
307307
$file = _realpath($file);
308308

309-
if ($file !== false && ! is_file($file)) {
309+
if ($file === false || ! is_file($file)) {
310310
return null;
311311
}
312312

system/View/View.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
281281
$this->renderVars['file'] = clean_path($this->renderVars['file']);
282282
$this->renderVars['file'] = ++$this->viewsCount . ' ' . $this->renderVars['file'];
283283

284-
$output = '<!-- DEBUG-VIEW START ' . $this->renderVars['file'] . ' -->' . "\n"
284+
$output = '<!-- DEBUG-VIEW START ' . $this->renderVars['file'] . " -->\n"
285285
. $output . "\n"
286-
. '<!-- DEBUG-VIEW ENDED ' . $this->renderVars['file'] . ' -->' . "\n";
286+
. '<!-- DEBUG-VIEW ENDED ' . $this->renderVars['file'] . " -->\n";
287287
}
288288
}
289289

tests/system/Autoloader/FileLocatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function testListFilesSimple(): void
231231
{
232232
$files = $this->locator->listFiles('Config/');
233233

234-
$this->assertTrue(in_array(APPPATH . 'Config/App.php', $files, true));
234+
$this->assertContains(APPPATH . 'Config/App.php', $files);
235235
}
236236

237237
public function testListFilesDoesNotContainDirectories(): void

tests/system/CLI/CLITest.php

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -323,31 +323,31 @@ public function testWrite(): void
323323
{
324324
CLI::write('test');
325325

326-
$expected = "\n" . 'test' . "\n";
326+
$expected = "\ntest\n";
327327
$this->assertSame($expected, $this->getStreamFilterBuffer());
328328
}
329329

330330
public function testWriteForeground(): void
331331
{
332332
CLI::write('test', 'red');
333333

334-
$expected = "\033[0;31mtest\033[0m" . "\n";
334+
$expected = "\033[0;31mtest\033[0m\n";
335335
$this->assertSame($expected, $this->getStreamFilterBuffer());
336336
}
337337

338338
public function testWriteForegroundWithColorBefore(): void
339339
{
340340
CLI::write(CLI::color('green', 'green') . ' red', 'red');
341341

342-
$expected = "\033[0;32mgreen\033[0m\033[0;31m red\033[0m" . "\n";
342+
$expected = "\033[0;32mgreen\033[0m\033[0;31m red\033[0m\n";
343343
$this->assertSame($expected, $this->getStreamFilterBuffer());
344344
}
345345

346346
public function testWriteForegroundWithColorAfter(): void
347347
{
348348
CLI::write('red ' . CLI::color('green', 'green'), 'red');
349349

350-
$expected = "\033[0;31mred \033[0m\033[0;32mgreen\033[0m" . "\n";
350+
$expected = "\033[0;31mred \033[0m\033[0;32mgreen\033[0m\n";
351351
$this->assertSame($expected, $this->getStreamFilterBuffer());
352352
}
353353

@@ -361,15 +361,15 @@ public function testWriteForegroundWithColorTwice(): void
361361
'red'
362362
);
363363

364-
$expected = "\033[0;32mgreen\033[0m\033[0;31m red \033[0m\033[0;32mgreen\033[0m" . "\n";
364+
$expected = "\033[0;32mgreen\033[0m\033[0;31m red \033[0m\033[0;32mgreen\033[0m\n";
365365
$this->assertSame($expected, $this->getStreamFilterBuffer());
366366
}
367367

368368
public function testWriteBackground(): void
369369
{
370370
CLI::write('test', 'red', 'green');
371371

372-
$expected = "\033[0;31m\033[42mtest\033[0m" . "\n";
372+
$expected = "\033[0;31m\033[42mtest\033[0m\n";
373373
$this->assertSame($expected, $this->getStreamFilterBuffer());
374374
}
375375

@@ -378,23 +378,23 @@ public function testError(): void
378378
CLI::error('test');
379379

380380
// red expected cuz stderr
381-
$expected = "\033[1;31mtest\033[0m" . "\n";
381+
$expected = "\033[1;31mtest\033[0m\n";
382382
$this->assertSame($expected, $this->getStreamFilterBuffer());
383383
}
384384

385385
public function testErrorForeground(): void
386386
{
387387
CLI::error('test', 'purple');
388388

389-
$expected = "\033[0;35mtest\033[0m" . "\n";
389+
$expected = "\033[0;35mtest\033[0m\n";
390390
$this->assertSame($expected, $this->getStreamFilterBuffer());
391391
}
392392

393393
public function testErrorBackground(): void
394394
{
395395
CLI::error('test', 'purple', 'green');
396396

397-
$expected = "\033[0;35m\033[42mtest\033[0m" . "\n";
397+
$expected = "\033[0;35m\033[42mtest\033[0m\n";
398398
$this->assertSame($expected, $this->getStreamFilterBuffer());
399399
}
400400

@@ -411,16 +411,16 @@ public function testShowProgress(): void
411411
CLI::write('third.');
412412
CLI::showProgress(1, 20);
413413

414-
$expected = 'first.' . "\n" .
415-
"[\033[32m#.........\033[0m] 5% Complete" . "\n" .
416-
"\033[1A[\033[32m#####.....\033[0m] 50% Complete" . "\n" .
417-
"\033[1A[\033[32m##########\033[0m] 100% Complete" . "\n" .
418-
'second.' . "\n" .
419-
"[\033[32m#.........\033[0m] 5% Complete" . "\n" .
420-
"\033[1A[\033[32m#####.....\033[0m] 50% Complete" . "\n" .
421-
"\033[1A[\033[32m##########\033[0m] 100% Complete" . "\n" .
422-
'third.' . "\n" .
423-
"[\033[32m#.........\033[0m] 5% Complete" . "\n";
414+
$expected = "first.\n" .
415+
"[\033[32m#.........\033[0m] 5% Complete\n" .
416+
"\033[1A[\033[32m#####.....\033[0m] 50% Complete\n" .
417+
"\033[1A[\033[32m##########\033[0m] 100% Complete\n" .
418+
"second.\n" .
419+
"[\033[32m#.........\033[0m] 5% Complete\n" .
420+
"\033[1A[\033[32m#####.....\033[0m] 50% Complete\n" .
421+
"\033[1A[\033[32m##########\033[0m] 100% Complete\n" .
422+
"third.\n" .
423+
"[\033[32m#.........\033[0m] 5% Complete\n";
424424
$this->assertSame($expected, $this->getStreamFilterBuffer());
425425
}
426426

@@ -431,24 +431,24 @@ public function testShowProgressWithoutBar(): void
431431
CLI::showProgress(false, 20);
432432
CLI::showProgress(false, 20);
433433

434-
$expected = 'first.' . "\n" . "\007\007\007";
434+
$expected = "first.\n\007\007\007";
435435
$this->assertSame($expected, $this->getStreamFilterBuffer());
436436
}
437437

438438
public function testWrap(): void
439439
{
440440
$this->assertSame('', CLI::wrap(''));
441441
$this->assertSame(
442-
'1234' . "\n" . ' 5678' . "\n" . ' 90' . "\n" . ' abc' . "\n" . ' de' . "\n" . ' fghij' . "\n" . ' 0987654321',
443-
CLI::wrap('1234 5678 90' . "\n" . 'abc de fghij' . "\n" . '0987654321', 5, 1)
442+
"1234\n 5678\n 90\n abc\n de\n fghij\n 0987654321",
443+
CLI::wrap("1234 5678 90\nabc de fghij\n0987654321", 5, 1)
444444
);
445445
$this->assertSame(
446-
'1234 5678 90' . "\n" . ' abc de fghij' . "\n" . ' 0987654321',
447-
CLI::wrap('1234 5678 90' . "\n" . 'abc de fghij' . "\n" . '0987654321', 999, 2)
446+
"1234 5678 90\n abc de fghij\n 0987654321",
447+
CLI::wrap("1234 5678 90\nabc de fghij\n0987654321", 999, 2)
448448
);
449449
$this->assertSame(
450-
'1234 5678 90' . "\n" . 'abc de fghij' . "\n" . '0987654321',
451-
CLI::wrap('1234 5678 90' . "\n" . 'abc de fghij' . "\n" . '0987654321')
450+
"1234 5678 90\nabc de fghij\n0987654321",
451+
CLI::wrap("1234 5678 90\nabc de fghij\n0987654321")
452452
);
453453
}
454454

@@ -605,38 +605,38 @@ public static function provideTable(): iterable
605605
[
606606
$oneRow,
607607
[],
608-
'+---+-----+' . "\n" .
609-
'| 1 | bar |' . "\n" .
610-
'+---+-----+' . "\n" . "\n",
608+
"+---+-----+\n" .
609+
"| 1 | bar |\n" .
610+
"+---+-----+\n\n",
611611
],
612612
[
613613
$oneRow,
614614
$head,
615-
'+----+-------+' . "\n" .
616-
'| ID | Title |' . "\n" .
617-
'+----+-------+' . "\n" .
618-
'| 1 | bar |' . "\n" .
619-
'+----+-------+' . "\n" . "\n",
615+
"+----+-------+\n" .
616+
"| ID | Title |\n" .
617+
"+----+-------+\n" .
618+
"| 1 | bar |\n" .
619+
"+----+-------+\n\n",
620620
],
621621
[
622622
$manyRows,
623623
[],
624-
'+---+-----------------+' . "\n" .
625-
'| 1 | bar |' . "\n" .
626-
'| 2 | bar * 2 |' . "\n" .
627-
'| 3 | bar + bar + bar |' . "\n" .
628-
'+---+-----------------+' . "\n" . "\n",
624+
"+---+-----------------+\n" .
625+
"| 1 | bar |\n" .
626+
"| 2 | bar * 2 |\n" .
627+
"| 3 | bar + bar + bar |\n" .
628+
"+---+-----------------+\n\n",
629629
],
630630
[
631631
$manyRows,
632632
$head,
633-
'+----+-----------------+' . "\n" .
634-
'| ID | Title |' . "\n" .
635-
'+----+-----------------+' . "\n" .
636-
'| 1 | bar |' . "\n" .
637-
'| 2 | bar * 2 |' . "\n" .
638-
'| 3 | bar + bar + bar |' . "\n" .
639-
'+----+-----------------+' . "\n" . "\n",
633+
"+----+-----------------+\n" .
634+
"| ID | Title |\n" .
635+
"+----+-----------------+\n" .
636+
"| 1 | bar |\n" .
637+
"| 2 | bar * 2 |\n" .
638+
"| 3 | bar + bar + bar |\n" .
639+
"+----+-----------------+\n\n",
640640
],
641641
// Multibyte letters
642642
[
@@ -650,11 +650,11 @@ public static function provideTable(): iterable
650650
'ID',
651651
'タイトル',
652652
],
653-
'+------+----------+' . "\n" .
654-
'| ID | タイトル |' . "\n" .
655-
'+------+----------+' . "\n" .
656-
'| ほげ | bar |' . "\n" .
657-
'+------+----------+' . "\n" . "\n",
653+
"+------+----------+\n" .
654+
"| ID | タイトル |\n" .
655+
"+------+----------+\n" .
656+
"| ほげ | bar |\n" .
657+
"+------+----------+\n\n",
658658
],
659659
];
660660
}

tests/system/Files/FileCollectionTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public function testResolveDirectorySymlink(): void
7272

7373
$this->assertSame($this->directory, $method($link));
7474

75-
rmdir($link);
75+
if (is_windows() && is_dir($link)) {
76+
rmdir($link);
77+
} else {
78+
unlink($link);
79+
}
7680
}
7781

7882
public function testResolveFileFile(): void

0 commit comments

Comments
 (0)