File tree 1 file changed +14
-9
lines changed
1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 11
11
12
12
use function is_array ;
13
13
use function ltrim ;
14
+ use function trigger_error ;
15
+
16
+ use const E_USER_DEPRECATED ;
14
17
15
18
/**
16
19
* Use this annotation to validate a parameter for a query or mutation.
29
32
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER )]
30
33
class Assertion implements ParameterAnnotationInterface
31
34
{
32
- private ? string $ for = null ;
35
+ private string | null $ for = null ;
33
36
/** @var Constraint[] */
34
37
private array $ constraint ;
35
38
@@ -51,15 +54,17 @@ public function __construct(
51
54
52
55
$ this ->constraint = is_array ($ constraint ) ? $ constraint : [$ constraint ];
53
56
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 ;
62
59
}
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 , '$ ' );
63
68
}
64
69
65
70
public function getTarget (): string
You can’t perform that action at this time.
0 commit comments