You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Command/Command.php
+34-4
Original file line number
Diff line number
Diff line change
@@ -54,17 +54,27 @@ class Command
54
54
privatearray$usages = [];
55
55
private ?HelperSet$helperSet = null;
56
56
57
+
/**
58
+
* @deprecated since Symfony 7.3, use the #[AsCommand] attribute instead
59
+
*/
57
60
publicstaticfunctiongetDefaultName(): ?string
58
61
{
62
+
trigger_deprecation('symfony/console', '7.3', 'Method "%s()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', __METHOD__);
63
+
59
64
if ($attribute = (new \ReflectionClass(static::class))->getAttributes(AsCommand::class)) {
60
65
return$attribute[0]->newInstance()->name;
61
66
}
62
67
63
68
returnnull;
64
69
}
65
70
71
+
/**
72
+
* @deprecated since Symfony 7.3, use the #[AsCommand] attribute instead
trigger_deprecation('symfony/console', '7.3', 'Method "%s()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', __METHOD__);
77
+
68
78
if ($attribute = (new \ReflectionClass(static::class))->getAttributes(AsCommand::class)) {
69
79
return$attribute[0]->newInstance()->description;
70
80
}
@@ -81,7 +91,19 @@ public function __construct(?string $name = null)
if (self::class !== (new \ReflectionMethod($this, 'getDefaultName'))->getDeclaringClass()->getName()) {
98
+
trigger_deprecation('symfony/console', '7.3', 'Method "%s::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', static::class);
if (self::class !== (new \ReflectionMethod($this, 'getDefaultDescription'))->getDeclaringClass()->getName()) {
123
+
trigger_deprecation('symfony/console', '7.3', 'Method "%s::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', static::class);
if (Command::class !== (new \ReflectionMethod($class, 'getDefaultName'))->getDeclaringClass()->getName()) {
65
+
trigger_deprecation('symfony/console', '7.3', 'Method "%s::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', $class);
if (Command::class !== (new \ReflectionMethod($class, 'getDefaultDescription'))->getDeclaringClass()->getName()) {
128
+
trigger_deprecation('symfony/console', '7.3', 'Method "%s::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.', $class);
$this->assertSame('This is a command I wrote all by myself', MyAnnotatedCommand::getDefaultDescription());
447
+
$this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.');
448
+
$this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.');
$this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.');
468
+
$this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.');
0 commit comments