Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
private readonly MigrationDetector $detector,
) {
}

#[\Override]
public function name(): string
{
Expand Down
40 changes: 20 additions & 20 deletions src/Configuration/KcodeComposerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
final class KcodeComposerGenerator implements ConfigGenerator
{
private const array DEFAULT_TOOL_VERSIONS = [
'phpunit/phpunit' => '^12.5',
'phpstan/phpstan' => '^2.0',
'friendsofphp/php-cs-fixer' => '^3.64',
'rector/rector' => '^2.0',
'vimeo/psalm' => '^6.0',
'phpunit/phpunit' => '^12.5',
'phpstan/phpstan' => '^2.0',
'friendsofphp/php-cs-fixer' => '^3.64',
'rector/rector' => '^2.0',
'vimeo/psalm' => '^6.0',
];

/** @var array<string, string> Maps devkit.php tool short-names → Composer package names */
private const array TOOL_SHORT_NAME_MAP = [
'phpunit' => 'phpunit/phpunit',
'phpstan' => 'phpstan/phpstan',
'php-cs-fixer' => 'friendsofphp/php-cs-fixer',
'rector' => 'rector/rector',
'psalm' => 'vimeo/psalm',
'phpunit' => 'phpunit/phpunit',
'phpstan' => 'phpstan/phpstan',
'php-cs-fixer' => 'friendsofphp/php-cs-fixer',
'rector' => 'rector/rector',
'psalm' => 'vimeo/psalm',
];

#[\Override]
Expand All @@ -57,23 +57,23 @@ public function generate(ProjectContext $context): string
$require = $this->resolveVersions($context->toolVersions);

$manifest = [
'name' => 'kariricode/devkit-tools',
'name' => 'kariricode/devkit-tools',
'description' => 'Dev toolchain managed by kcode — do not edit manually.',
'require' => $require,
'config' => [
'bin-compat' => 'full',
'optimize-autoloader' => true,
'sort-packages' => true,
'preferred-install' => 'dist',
'allow-plugins' => [
'require' => $require,
'config' => [
'bin-compat' => 'full',
'optimize-autoloader' => true,
'sort-packages' => true,
'preferred-install' => 'dist',
'allow-plugins' => [
'infection/extension-installer' => false,
],
],
'minimum-stability' => 'stable',
'prefer-stable' => true,
'prefer-stable' => true,
];

return json_encode($manifest, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES) . \PHP_EOL;
return (string) json_encode($manifest, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES) . \PHP_EOL;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Core/Devkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function init(string $workingDirectory = '.'): int
*/
public function installTools(string $workingDirectory = '.'): int
{
$context = $this->context($workingDirectory);
$devkitDirectory = $context->devkitDir;
$context = $this->context($workingDirectory);
$devkitDirectory = $context->devkitDir;
$composerManifestPath = $devkitDirectory . \DIRECTORY_SEPARATOR . 'composer.json';

if (! is_file($composerManifestPath)) {
Expand All @@ -115,7 +115,7 @@ public function installTools(string $workingDirectory = '.'): int
}

$composerBinary = $this->composerResolver->resolve();
$command = [
$command = [
$composerBinary,
'install',
'--working-dir=' . $devkitDirectory,
Expand Down Expand Up @@ -285,5 +285,4 @@ private function removeRecursive(string $dir): void

rmdir($dir);
}

}
1 change: 0 additions & 1 deletion src/Core/ProcessExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,4 @@ public function resolveBinary(string $vendorBin): ?string

return null;
}

}
8 changes: 4 additions & 4 deletions tests/Unit/Configuration/KcodeComposerGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function outputPathIsComposerJson(): void
public function generateProducesValidJsonWithDefaultVersions(): void
{
$generator = new KcodeComposerGenerator();
$output = $generator->generate($this->context);
$output = $generator->generate($this->context);

/** @var array<string, mixed> $manifest */
$manifest = json_decode($output, true, 512, \JSON_THROW_ON_ERROR);
Expand Down Expand Up @@ -93,7 +93,7 @@ public function generateRespectsUserToolVersionOverrides(): void
);

$generator = new KcodeComposerGenerator();
$output = $generator->generate($contextWithVersions);
$output = $generator->generate($contextWithVersions);

/** @var array<string, mixed> $manifest */
$manifest = json_decode($output, true, 512, \JSON_THROW_ON_ERROR);
Expand All @@ -109,7 +109,7 @@ public function generateRespectsUserToolVersionOverrides(): void
public function generateIncludesComposerConfigSection(): void
{
$generator = new KcodeComposerGenerator();
$output = $generator->generate($this->context);
$output = $generator->generate($this->context);

/** @var array<string, mixed> $manifest */
$manifest = json_decode($output, true, 512, \JSON_THROW_ON_ERROR);
Expand All @@ -123,7 +123,7 @@ public function generateIncludesComposerConfigSection(): void
public function generateOutputEndsWithNewline(): void
{
$generator = new KcodeComposerGenerator();
$output = $generator->generate($this->context);
$output = $generator->generate($this->context);

$this->assertStringEndsWith(\PHP_EOL, $output);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Core/ComposerResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class ComposerResolverTest extends TestCase
public function resolveReturnsNonEmptyString(): void
{
$resolver = new ComposerResolver();
$result = $resolver->resolve();
$result = $resolver->resolve();

$this->assertIsString($result);
$this->assertNotEmpty($result);
Expand All @@ -26,7 +26,7 @@ public function resolveReturnsNonEmptyString(): void
public function resolveDoesNotReturnShellFragment(): void
{
$resolver = new ComposerResolver();
$result = $resolver->resolve();
$result = $resolver->resolve();

// Must be a single executable path — no shell fragments like "php /path/to/file"
// (a shell fragment would break proc_open's array invocation)
Expand All @@ -42,7 +42,7 @@ public function resolveRespectsComposerBinaryEnvironmentVariable(): void
putenv('COMPOSER_BINARY=/usr/bin/env');

$resolver = new ComposerResolver();
$result = $resolver->resolve();
$result = $resolver->resolve();

$this->assertSame('/usr/bin/env', $result);

Expand All @@ -62,7 +62,7 @@ public function resolveIgnoresNonExecutableComposerBinaryEnvVar(): void
putenv('COMPOSER_BINARY=/non/existent/path/composer');

$resolver = new ComposerResolver();
$result = $resolver->resolve();
$result = $resolver->resolve();

// Should fall through to PATH or fallback — not return the non-executable path
$this->assertNotSame('/non/existent/path/composer', $result);
Expand Down