Issues (169)

src/Attribute/InputObjectField.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Attribute;
6
7
use Attribute;
8
use ReflectionProperty;
9
use Spiral\Attributes\NamedArgumentConstructor;
10
11
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
12
final class InputObjectField extends AbstractField
13
{
14
    public readonly mixed $defaultValue;
15
16 3
    public function __construct(
17
        ?string $name = null,
18
        ?string $description = null,
19
        ?string $type = null,
20
        ?int $mode = null,
21
        ?string $deprecationReason = null,
22
        mixed $defaultValue = null,
23
    ) {
24 3
        parent::__construct($name, $description, $type, $mode, $deprecationReason);
25
26 3
        if (\func_num_args() >= 6) {
27 2
            $this->defaultValue = $defaultValue;
0 ignored issues
show
The property defaultValue is declared read-only in Andi\GraphQL\Attribute\InputObjectField.
Loading history...
28
        }
29
    }
30
31 3
    public function hasDefaultValue(): bool
32
    {
33 3
        return (new ReflectionProperty($this, 'defaultValue'))->isInitialized($this);
34
    }
35
}
36