File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace TheCodingMachine \GraphQLite \Annotations ;
6
6
7
+ use Attribute ;
7
8
use BadMethodCallException ;
8
9
9
10
use function ltrim ;
18
19
* @Attribute("for", type = "string")
19
20
* })
20
21
*/
22
+ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE )]
21
23
class HideParameter implements ParameterAnnotationInterface
22
24
{
23
25
/** @var string */
@@ -26,13 +28,13 @@ class HideParameter implements ParameterAnnotationInterface
26
28
/**
27
29
* @param array<string, mixed> $values
28
30
*/
29
- public function __construct (array $ values = [])
31
+ public function __construct (array $ values = [], ? string $ for = null )
30
32
{
31
- if (! isset ($ values ['for ' ])) {
33
+ if (! isset ($ for ) && ! isset ( $ values ['for ' ])) {
32
34
return ;
33
35
}
34
36
35
- $ this ->for = ltrim ($ values ['for ' ], '$ ' );
37
+ $ this ->for = ltrim ($ for ?? $ values ['for ' ], '$ ' );
36
38
}
37
39
38
40
public function getTarget (): string
Original file line number Diff line number Diff line change 4
4
5
5
namespace TheCodingMachine \GraphQLite \Annotations ;
6
6
7
+ use Attribute ;
7
8
use BadMethodCallException ;
8
9
9
10
use function ltrim ;
18
19
* @Attribute("for", type = "string")
19
20
* })
20
21
*/
22
+ #[Attribute(Attribute::TARGET_METHOD )]
21
23
class InjectUser implements ParameterAnnotationInterface
22
24
{
23
25
/** @var string */
@@ -26,13 +28,13 @@ class InjectUser implements ParameterAnnotationInterface
26
28
/**
27
29
* @param array<string, mixed> $values
28
30
*/
29
- public function __construct (array $ values = [])
31
+ public function __construct (array $ values = [], ? string $ for = null )
30
32
{
31
- if (! isset ($ values ['for ' ])) {
33
+ if (! isset ($ for ) && ! isset ( $ values ['for ' ])) {
32
34
return ;
33
35
}
34
36
35
- $ this ->for = ltrim ($ values ['for ' ], '$ ' );
37
+ $ this ->for = ltrim ($ for ?? $ values ['for ' ], '$ ' );
36
38
}
37
39
38
40
public function getTarget (): string
Original file line number Diff line number Diff line change 4
4
5
5
namespace TheCodingMachine \GraphQLite \Annotations ;
6
6
7
+ use Attribute ;
7
8
use BadMethodCallException ;
8
9
9
10
use function is_string ;
19
20
* @Attribute("inputType", type = "string"),
20
21
* })
21
22
*/
23
+ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE )]
22
24
class UseInputType implements ParameterAnnotationInterface
23
25
{
24
26
/** @var string|null */
@@ -31,7 +33,7 @@ class UseInputType implements ParameterAnnotationInterface
31
33
*
32
34
* @throws BadMethodCallException
33
35
*/
34
- public function __construct ($ inputType = [])
36
+ public function __construct ($ inputType = [], ? string $ for = null )
35
37
{
36
38
$ values = $ inputType ;
37
39
if (is_string ($ values )) {
@@ -41,11 +43,11 @@ public function __construct($inputType = [])
41
43
throw new BadMethodCallException ('The @UseInputType annotation must be passed an input type. For instance: "@UseInputType(for="$input", inputType="MyInputType")" in PHP 7+ or #[UseInputType("MyInputType")] in PHP 8+ ' );
42
44
}
43
45
$ this ->inputType = $ values ['inputType ' ];
44
- if (! isset ($ values ['for ' ])) {
46
+ if (! isset ($ for ) &&! isset ( $ values ['for ' ])) {
45
47
return ;
46
48
}
47
49
48
- $ this ->for = ltrim ($ values ['for ' ], '$ ' );
50
+ $ this ->for = ltrim ($ for ?? $ values ['for ' ], '$ ' );
49
51
}
50
52
51
53
public function getTarget (): string
You can’t perform that action at this time.
0 commit comments