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
@@ -69,25 +68,29 @@ public static function tryFrom(\ReflectionParameter $parameter): ?self
69
68
thrownewLogicException(\sprintf('The type "%s" of parameter "$%s" is not supported as a command option. Only "%s" types are allowed.', $self->typeName, $name, implode('", "', self::ALLOWED_TYPES)));
70
69
}
71
70
71
+
if (!$parameter->isDefaultValueAvailable()) {
72
+
thrownewLogicException(\sprintf('The option parameter "$%s" must declare a default value.', $name));
Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Command/InvokableCommand.php
+28-4
Original file line number
Diff line number
Diff line change
@@ -30,14 +30,16 @@
30
30
*/
31
31
class InvokableCommand
32
32
{
33
+
privatereadonly\Closure$code;
33
34
privatereadonly\ReflectionFunction$reflection;
34
35
35
36
publicfunction__construct(
36
37
privatereadonlyCommand$command,
37
-
privatereadonly\Closure$code,
38
+
callable$code,
38
39
privatereadonlybool$triggerDeprecations = false,
39
40
) {
40
-
$this->reflection = new \ReflectionFunction($code);
41
+
$this->code = $this->getClosure($code);
42
+
$this->reflection = new \ReflectionFunction($this->code);
41
43
}
42
44
43
45
/**
@@ -49,7 +51,7 @@ public function __invoke(InputInterface $input, OutputInterface $output): int
49
51
50
52
if (null !== $statusCode && !\is_int($statusCode)) {
51
53
if ($this->triggerDeprecations) {
52
-
trigger_deprecation('symfony/console', '7.3', \sprintf('Returning a non-integer value from the command "%s" is deprecated and will throw an exception in PHP 8.0.', $this->command->getName()));
54
+
trigger_deprecation('symfony/console', '7.3', \sprintf('Returning a non-integer value from the command "%s" is deprecated and will throw an exception in Symfony 8.0.', $this->command->getName()));
53
55
54
56
return0;
55
57
}
@@ -77,6 +79,28 @@ public function configure(InputDefinition $definition): void
@@ -97,7 +121,7 @@ private function getParameters(InputInterface $input, OutputInterface $output):
97
121
98
122
if (!$typeinstanceof \ReflectionNamedType) {
99
123
if ($this->triggerDeprecations) {
100
-
trigger_deprecation('symfony/console', '7.3', \sprintf('Omitting the type declaration for the parameter "$%s" is deprecated and will throw an exception in PHP 8.0.', $parameter->getName()));
124
+
trigger_deprecation('symfony/console', '7.3', \sprintf('Omitting the type declaration for the parameter "$%s" is deprecated and will throw an exception in Symfony 8.0.', $parameter->getName()));
0 commit comments