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
The exception messages now include the method:
> The option parameter "$a" of "App\Command\SendSalesReportsCommand::__invoke()" must declare a default value.
thrownewLogicException(\sprintf('The parameter "$%s" must have a named type. Untyped, Union or Intersection types are not supported for command arguments.', $name));
66
+
thrownewLogicException(\sprintf('The parameter "$%s" of "%s()" must have a named type. Untyped, Union or Intersection types are not supported for command arguments.', $name, $self->function));
60
67
}
61
68
62
69
$parameterTypeName = $type->getName();
63
70
64
71
if (!\in_array($parameterTypeName, self::ALLOWED_TYPES, true)) {
65
-
thrownewLogicException(\sprintf('The type "%s" of parameter "$%s" is not supported as a command argument. Only "%s" types are allowed.', $parameterTypeName, $name, implode('", "', self::ALLOWED_TYPES)));
72
+
thrownewLogicException(\sprintf('The type "%s" on parameter "$%s" of "%s()" is not supported as a command argument. Only "%s" types are allowed.', $parameterTypeName, $name, $self->function, implode('", "', self::ALLOWED_TYPES)));
thrownewLogicException(\sprintf('The option parameter "$%s" must declare a default value.', $name));
71
+
thrownewLogicException(\sprintf('The option parameter "$%s" of "%s()" must declare a default value.', $name, $self->function));
65
72
}
66
73
67
74
if (!$self->name) {
@@ -76,21 +83,21 @@ public static function tryFrom(\ReflectionParameter $parameter): ?self
76
83
}
77
84
78
85
if (!$typeinstanceof \ReflectionNamedType) {
79
-
thrownewLogicException(\sprintf('The parameter "$%s" must have a named type. Untyped or Intersection types are not supported for command options.', $name));
86
+
thrownewLogicException(\sprintf('The parameter "$%s" of "%s()" must have a named type. Untyped or Intersection types are not supported for command options.', $name, $self->function));
80
87
}
81
88
82
89
$self->typeName = $type->getName();
83
90
84
91
if (!\in_array($self->typeName, self::ALLOWED_TYPES, true)) {
85
-
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)));
92
+
thrownewLogicException(\sprintf('The type "%s" on parameter "$%s" of "%s()" is not supported as a command option. Only "%s" types are allowed.', $self->typeName, $name, $self->function, implode('", "', self::ALLOWED_TYPES)));
thrownewLogicException(\sprintf('The option parameter "$%s" must not be nullable when it has a default boolean value.', $name));
96
+
thrownewLogicException(\sprintf('The option parameter "$%s" of "%s()" must not be nullable when it has a default boolean value.', $name, $self->function));
90
97
}
91
98
92
99
if ($self->allowNull && null !== $self->default) {
93
-
thrownewLogicException(\sprintf('The option parameter "$%s" must either be not-nullable or have a default of null.', $name));
100
+
thrownewLogicException(\sprintf('The option parameter "$%s" of "%s()" must either be not-nullable or have a default of null.', $name, $self->function));
94
101
}
95
102
96
103
if ('bool' === $self->typeName) {
@@ -160,11 +167,11 @@ private function handleUnion(\ReflectionUnionType $type): self
if (!\in_array($this->typeName, self::ALLOWED_UNION_TYPES, true)) {
163
-
thrownewLogicException(\sprintf('The union type for parameter "$%s" is not supported as a command option. Only "%s" types are allowed.', $this->name, implode('", "', self::ALLOWED_UNION_TYPES)));
170
+
thrownewLogicException(\sprintf('The union type for parameter "$%s" of "%s()" is not supported as a command option. Only "%s" types are allowed.', $this->name, $this->function, implode('", "', self::ALLOWED_UNION_TYPES)));
164
171
}
165
172
166
173
if (false !== $this->default) {
167
-
thrownewLogicException(\sprintf('The option parameter "$%s" must have a default value of false.', $this->name));
174
+
thrownewLogicException(\sprintf('The option parameter "$%s" of "%s()" must have a default value of false.', $this->name, $this->function));
$this->expectExceptionMessage('The type "object" of parameter "$any" is not supported as a command argument. Only "string", "bool", "int", "float", "array" types are allowed.');
143
+
$this->expectExceptionMessage(\sprintf('The type "object" on parameter "$any" of "%s" is not supported as a command argument. Only "string", "bool", "int", "float", "array" types are allowed.', self::FUNCTION_NAME));
142
144
143
145
$command->getDefinition();
144
146
}
@@ -149,7 +151,7 @@ public function testInvalidOptionType()
$this->expectExceptionMessage('The type "object" of parameter "$any" is not supported as a command option. Only "string", "bool", "int", "float", "array" types are allowed.');
154
+
$this->expectExceptionMessage(\sprintf('The type "object" on parameter "$any" of "%s" is not supported as a command option. Only "string", "bool", "int", "float", "array" types are allowed.', self::FUNCTION_NAME));
153
155
154
156
$command->getDefinition();
155
157
}
@@ -337,39 +339,39 @@ public static function provideInvalidOptionDefinitions(): \Generator
337
339
{
338
340
yield'no-default' => [
339
341
function (#[Option] string$a) {},
340
-
'The option parameter "$a" must declare a default value.',
342
+
\sprintf('The option parameter "$a" of "%s" must declare a default value.', self::FUNCTION_NAME),
341
343
];
342
344
yield'nullable-bool-default-true' => [
343
345
function (#[Option] ?bool$a = true) {},
344
-
'The option parameter "$a" must not be nullable when it has a default boolean value.',
346
+
\sprintf('The option parameter "$a" of "%s" must not be nullable when it has a default boolean value.', self::FUNCTION_NAME),
345
347
];
346
348
yield'nullable-bool-default-false' => [
347
349
function (#[Option] ?bool$a = false) {},
348
-
'The option parameter "$a" must not be nullable when it has a default boolean value.',
350
+
\sprintf('The option parameter "$a" of "%s" must not be nullable when it has a default boolean value.', self::FUNCTION_NAME),
349
351
];
350
352
yield'invalid-union-type' => [
351
353
function (#[Option] array|bool$a = false) {},
352
-
'The union type for parameter "$a" is not supported as a command option. Only "bool|string", "bool|int", "bool|float" types are allowed.',
354
+
\sprintf('The union type for parameter "$a" of "%s" is not supported as a command option. Only "bool|string", "bool|int", "bool|float" types are allowed.', self::FUNCTION_NAME),
353
355
];
354
356
yield'union-type-cannot-allow-null' => [
355
357
function (#[Option] string|bool|null$a = null) {},
356
-
'The union type for parameter "$a" is not supported as a command option. Only "bool|string", "bool|int", "bool|float" types are allowed.',
358
+
\sprintf('The union type for parameter "$a" of "%s" is not supported as a command option. Only "bool|string", "bool|int", "bool|float" types are allowed.', self::FUNCTION_NAME),
357
359
];
358
360
yield'union-type-default-true' => [
359
361
function (#[Option] string|bool$a = true) {},
360
-
'The option parameter "$a" must have a default value of false.',
362
+
\sprintf('The option parameter "$a" of "%s" must have a default value of false.', self::FUNCTION_NAME),
361
363
];
362
364
yield'union-type-default-string' => [
363
365
function (#[Option] string|bool$a = 'foo') {},
364
-
'The option parameter "$a" must have a default value of false.',
366
+
\sprintf('The option parameter "$a" of "%s" must have a default value of false.', self::FUNCTION_NAME),
365
367
];
366
368
yield'nullable-string-not-null-default' => [
367
369
function (#[Option] ?string$a = 'foo') {},
368
-
'The option parameter "$a" must either be not-nullable or have a default of null.',
370
+
\sprintf('The option parameter "$a" of "%s" must either be not-nullable or have a default of null.', self::FUNCTION_NAME),
369
371
];
370
372
yield'nullable-array-not-null-default' => [
371
373
function (#[Option] ?array$a = []) {},
372
-
'The option parameter "$a" must either be not-nullable or have a default of null.',
374
+
\sprintf('The option parameter "$a" of "%s" must either be not-nullable or have a default of null.', self::FUNCTION_NAME),
0 commit comments