Skip to content

Commit 5bd6f47

Browse files
committed
Add DevTools self-update command
1 parent 6e2dd38 commit 5bd6f47

7 files changed

Lines changed: 58 additions & 8 deletions

File tree

src/Composer/Command/ProxyCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public function __construct(
4848
}
4949

5050
/**
51-
* @param InputInterface $input
52-
* @param OutputInterface $output
51+
* Executes the proxied Symfony command through Composer's command contract.
5352
*
54-
* @return int
53+
* @param InputInterface $input the Composer command input
54+
* @param OutputInterface $output the Composer command output
55+
*
56+
* @return int the proxied command status code
5557
*/
5658
protected function execute(InputInterface $input, OutputInterface $output): int
5759
{

src/Composer/DevToolsPluginInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
*/
2727
interface DevToolsPluginInterface extends PluginInterface
2828
{
29+
/**
30+
* @var list<string> composer command names and aliases that DevTools MUST NOT override
31+
*/
2932
public const array COMPOSER_COMMAND_NAMES = [
3033
'_complete',
3134
'about',

src/Reflection/ClassReflection.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@
2424

2525
/**
2626
* Centralizes small reflection lookups used by DevTools runtime metadata.
27+
*
28+
* This helper keeps command discovery code focused on command behavior instead of
29+
* raw reflection boilerplate.
2730
*/
2831
final class ClassReflection
2932
{
3033
/**
31-
* @param class-string $className
32-
* @param class-string $parentClass
34+
* Detects whether a class can be instantiated as a subclass of another class.
35+
*
36+
* @param class-string $className the class being inspected
37+
* @param class-string $parentClass the required parent class or interface
38+
*
39+
* @return bool true when the class is instantiable and extends or implements the expected parent
3340
*/
3441
public static function isInstantiableSubclassOf(string $className, string $parentClass): bool
3542
{
@@ -39,10 +46,15 @@ public static function isInstantiableSubclassOf(string $className, string $paren
3946
}
4047

4148
/**
42-
* @param class-string $className
43-
* @param class-string $attributeClass
49+
* Returns the first matching attribute arguments normalized by constructor parameter name.
50+
*
51+
* Positional arguments are mapped to their constructor parameter names so callers do not
52+
* need to understand how the attribute was declared at the call site.
53+
*
54+
* @param class-string $className the class being inspected
55+
* @param class-string $attributeClass the attribute class being read
4456
*
45-
* @return array<string, mixed>|null
57+
* @return array<string, mixed>|null the normalized argument map, or null when the attribute is absent
4658
*/
4759
public static function getAttributeArguments(string $className, string $attributeClass): ?array
4860
{

tests/Console/Command/SelfUpdateCommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,24 @@ final class SelfUpdateCommandTest extends TestCase
4242
{
4343
use ProphecyTrait;
4444

45+
/**
46+
* @var ObjectProphecy<SelfUpdateRunnerInterface>
47+
*/
4548
private ObjectProphecy $selfUpdateRunner;
4649

50+
/**
51+
* @var ObjectProphecy<LoggerInterface>
52+
*/
4753
private ObjectProphecy $logger;
4854

55+
/**
56+
* @var ObjectProphecy<InputInterface>
57+
*/
4958
private ObjectProphecy $input;
5059

60+
/**
61+
* @var ObjectProphecy<OutputInterface>
62+
*/
5163
private ObjectProphecy $output;
5264

5365
private SelfUpdateCommand $command;

tests/Reflection/ClassReflectionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,8 @@ public function getAttributeArgumentsWillNormalizePositionalArguments(): void
9090
}
9191
}
9292

93+
/**
94+
* Fixture command that declares AsCommand through positional arguments.
95+
*/
9396
#[AsCommand('fixture', 'Fixture command.', ['alias'])]
9497
final class FixtureCommandWithPositionalAttribute extends Command {}

tests/SelfUpdate/ComposerSelfUpdateRunnerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,24 @@ final class ComposerSelfUpdateRunnerTest extends TestCase
3535
{
3636
use ProphecyTrait;
3737

38+
/**
39+
* @var ObjectProphecy<ProcessBuilderInterface>
40+
*/
3841
private ObjectProphecy $processBuilder;
3942

43+
/**
44+
* @var ObjectProphecy<ProcessQueueInterface>
45+
*/
4046
private ObjectProphecy $processQueue;
4147

48+
/**
49+
* @var ObjectProphecy<Process>
50+
*/
4251
private ObjectProphecy $process;
4352

53+
/**
54+
* @var ObjectProphecy<OutputInterface>
55+
*/
4456
private ObjectProphecy $output;
4557

4658
private ComposerSelfUpdateRunner $runner;

tests/SelfUpdate/VersionCheckNotifierTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ final class VersionCheckNotifierTest extends TestCase
3838
{
3939
use ProphecyTrait;
4040

41+
/**
42+
* @var ObjectProphecy<VersionCheckerInterface>
43+
*/
4144
private ObjectProphecy $versionChecker;
4245

46+
/**
47+
* @var ObjectProphecy<OutputInterface>
48+
*/
4349
private ObjectProphecy $output;
4450

4551
private VersionCheckNotifier $notifier;

0 commit comments

Comments
 (0)