Skip to content

Commit 39c8168

Browse files
authored
Merge pull request #11 from KaririCode-Framework/develop
Develop
2 parents d5dfa6b + 96f1b03 commit 39c8168

7 files changed

Lines changed: 11 additions & 21 deletions

File tree

src/Command/AbstractCommand.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,7 @@ protected function confirm(string $question, bool $default = false): bool
8181
/** @param list<string> $arguments */
8282
protected function hasFlag(array $arguments, string ...$flags): bool
8383
{
84-
foreach ($flags as $flag) {
85-
if (\in_array($flag, $arguments, true)) {
86-
return true;
87-
}
88-
}
89-
90-
return false;
84+
return array_any($flags, fn ($flag): bool => \in_array($flag, $arguments, true));
9185
}
9286

9387
/**

src/Command/InitCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace KaririCode\Devkit\Command;
66

77
use KaririCode\Devkit\Core\Devkit;
8+
use KaririCode\Devkit\Core\MigrationDetector;
89

910
/**
1011
* Generates all config files inside `.kcode/`.
@@ -45,11 +46,11 @@ public function execute(Devkit $devkit, array $arguments): int
4546

4647
// Scaffold devkit.php if requested
4748
if ($this->hasFlag($arguments, '--config')) {
48-
$this->scaffoldDevkitConfig($context->projectRoot, $context);
49+
$this->scaffoldDevkitConfig($context->projectRoot);
4950
}
5051

5152
// Hint: detect redundant root-level configs and dev dependencies
52-
$detector = new \KaririCode\Devkit\Core\MigrationDetector();
53+
$detector = new MigrationDetector();
5354
$migration = $detector->detect($context->projectRoot);
5455

5556
if ($migration->hasRedundancies) {
@@ -64,7 +65,7 @@ public function execute(Devkit $devkit, array $arguments): int
6465
return 0;
6566
}
6667

67-
private function scaffoldDevkitConfig(string $projectRoot, \KaririCode\Devkit\Core\ProjectContext $context): void
68+
private function scaffoldDevkitConfig(string $projectRoot): void
6869
{
6970
$configPath = $projectRoot . \DIRECTORY_SEPARATOR . 'devkit.php';
7071

@@ -74,7 +75,7 @@ private function scaffoldDevkitConfig(string $projectRoot, \KaririCode\Devkit\Co
7475
return;
7576
}
7677

77-
$content = <<<'PHP'
78+
$content = <<<'PHP_WRAP'
7879
<?php
7980
8081
declare(strict_types=1);
@@ -146,7 +147,7 @@ private function scaffoldDevkitConfig(string $projectRoot, \KaririCode\Devkit\Co
146147
// 'psalm' => '^6.0',
147148
// ],
148149
];
149-
PHP;
150+
PHP_WRAP;
150151

151152
file_put_contents($configPath, $content . \PHP_EOL);
152153

src/Configuration/CsFixerConfigGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ private function exportRules(array $rules): string
7878
$export = (string) preg_replace('/^array \($/m', '[', $export);
7979
$export = (string) preg_replace('/^\)$/m', ']', $export);
8080
$export = str_replace('array (', '[', $export);
81-
$export = str_replace(')', ']', $export);
8281

83-
return $export;
82+
return str_replace(')', ']', $export);
8483
}
8584
}

src/Core/DevkitConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function toolVersions(): array
117117
/** @var array<string, string> $typed */
118118
$typed = array_filter(
119119
$tools,
120-
static fn (mixed $v): bool => \is_string($v),
120+
\is_string(...),
121121
);
122122

123123
return $typed;

src/Core/ProjectContext.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
final readonly class ProjectContext
1616
{
1717
public string $devkitDir;
18-
1918
public string $buildDir;
2019

2120
/**
@@ -63,13 +62,13 @@ public function buildPath(string $filename = ''): string
6362
/** @return list<string> Convert absolute source dirs to project-relative paths. */
6463
public function relativeSourceDirs(): array
6564
{
66-
return array_map(fn (string $dir): string => $this->relativize($dir), $this->sourceDirs);
65+
return array_map($this->relativize(...), $this->sourceDirs);
6766
}
6867

6968
/** @return list<string> Convert absolute test dirs to project-relative paths. */
7069
public function relativeTestDirs(): array
7170
{
72-
return array_map(fn (string $dir): string => $this->relativize($dir), $this->testDirs);
71+
return array_map($this->relativize(...), $this->testDirs);
7372
}
7473

7574
public function relativize(string $absolutePath): string

src/ValueObject/MigrationReport.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
final readonly class MigrationReport
1414
{
1515
public bool $hasRedundancies;
16-
1716
public int $totalItems;
1817

1918
/**

src/ValueObject/QualityReport.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
final readonly class QualityReport
1313
{
1414
public bool $passed;
15-
1615
public float $totalSeconds;
17-
1816
public int $failureCount;
1917

2018
/** @param list<ToolResult> $results */

0 commit comments

Comments
 (0)