Skip to content

Commit dd402ec

Browse files
committed
💄 Fix CS
1 parent 037f9ee commit dd402ec

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Annotations/Assertion.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use function is_array;
1313
use function ltrim;
14+
use function trigger_error;
15+
16+
use const E_USER_DEPRECATED;
1417

1518
/**
1619
* Use this annotation to validate a parameter for a query or mutation.
@@ -29,7 +32,7 @@
2932
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)]
3033
class Assertion implements ParameterAnnotationInterface
3134
{
32-
private ?string $for = null;
35+
private string|null $for = null;
3336
/** @var Constraint[] */
3437
private array $constraint;
3538

@@ -51,15 +54,17 @@ public function __construct(
5154

5255
$this->constraint = is_array($constraint) ? $constraint : [$constraint];
5356

54-
if (null !== $for) {
55-
trigger_error(
56-
"Using #[Assertion(for='" . $for . "', constaint='...')] on methods is deprecated in favor " .
57-
"of #[Assertion(constraint='...')] the parameter itself.",
58-
E_USER_DEPRECATED,
59-
);
60-
61-
$this->for = ltrim($for, '$');
57+
if ($for === null) {
58+
return;
6259
}
60+
61+
trigger_error(
62+
"Using #[Assertion(for='" . $for . "', constaint='...')] on methods is deprecated in favor " .
63+
"of #[Assertion(constraint='...')] the parameter itself.",
64+
E_USER_DEPRECATED,
65+
);
66+
67+
$this->for = ltrim($for, '$');
6368
}
6469

6570
public function getTarget(): string

0 commit comments

Comments
 (0)