Skip to content

Commit b811d6e

Browse files
committed
Replace attribute target from method to parameter
1 parent bd8aa48 commit b811d6e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/Annotations/HideParameter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @Attribute("for", type = "string")
2020
* })
2121
*/
22-
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
22+
#[Attribute(Attribute::TARGET_PARAMETER)]
2323
class HideParameter implements ParameterAnnotationInterface
2424
{
2525
/** @var string */
@@ -28,13 +28,13 @@ class HideParameter implements ParameterAnnotationInterface
2828
/**
2929
* @param array<string, mixed> $values
3030
*/
31-
public function __construct(array $values = [], ?string $for = null)
31+
public function __construct(array $values = [])
3232
{
33-
if (! isset($for) && ! isset($values['for'])) {
33+
if (! isset($values['for'])) {
3434
return;
3535
}
3636

37-
$this->for = ltrim($for ?? $values['for'], '$');
37+
$this->for = ltrim($values['for'], '$');
3838
}
3939

4040
public function getTarget(): string

src/Annotations/InjectUser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @Attribute("for", type = "string")
2020
* })
2121
*/
22-
#[Attribute(Attribute::TARGET_METHOD)]
22+
#[Attribute(Attribute::TARGET_PARAMETER)]
2323
class InjectUser implements ParameterAnnotationInterface
2424
{
2525
/** @var string */
@@ -28,13 +28,13 @@ class InjectUser implements ParameterAnnotationInterface
2828
/**
2929
* @param array<string, mixed> $values
3030
*/
31-
public function __construct(array $values = [], ?string $for = null)
31+
public function __construct(array $values = [])
3232
{
33-
if (! isset($for) && ! isset($values['for'])) {
33+
if (! isset($values['for'])) {
3434
return;
3535
}
3636

37-
$this->for = ltrim($for ?? $values['for'], '$');
37+
$this->for = ltrim($values['for'], '$');
3838
}
3939

4040
public function getTarget(): string

src/Annotations/UseInputType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @Attribute("inputType", type = "string"),
2121
* })
2222
*/
23-
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
23+
#[Attribute(Attribute::TARGET_PARAMETER)]
2424
class UseInputType implements ParameterAnnotationInterface
2525
{
2626
/** @var string|null */
@@ -33,7 +33,7 @@ class UseInputType implements ParameterAnnotationInterface
3333
*
3434
* @throws BadMethodCallException
3535
*/
36-
public function __construct($inputType = [], ?string $for = null)
36+
public function __construct($inputType = [])
3737
{
3838
$values = $inputType;
3939
if (is_string($values)) {
@@ -43,11 +43,11 @@ public function __construct($inputType = [], ?string $for = null)
4343
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+');
4444
}
4545
$this->inputType = $values['inputType'];
46-
if (! isset($for) && ! isset($values['for'])) {
46+
if (! isset($values['for'])) {
4747
return;
4848
}
4949

50-
$this->for = ltrim($for ?? $values['for'], '$');
50+
$this->for = ltrim($values['for'], '$');
5151
}
5252

5353
public function getTarget(): string

0 commit comments

Comments
 (0)