• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

48 of 48 new or added lines in 2 files covered. (100.0%)

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.69
/src/Tempest/Reflection/src/PropertyReflector.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Reflection;
6

7
use Error;
8
use ReflectionProperty as PHPReflectionProperty;
9

10
final readonly class PropertyReflector implements Reflector
11
{
12
    use HasAttributes;
13

14
    public function __construct(
696✔
15
        private PHPReflectionProperty $reflectionProperty,
16
    ) {}
696✔
17

18
    public static function fromParts(string|object $class, string $name): self
3✔
19
    {
20
        return new self(new PHPReflectionProperty($class, $name));
3✔
21
    }
22

23
    public function getReflection(): PHPReflectionProperty
695✔
24
    {
25
        return $this->reflectionProperty;
695✔
26
    }
27

28
    public function getValue(object $object): mixed
115✔
29
    {
30
        return $this->reflectionProperty->getValue($object);
115✔
31
    }
32

33
    public function setValue(object $object, mixed $value): void
120✔
34
    {
35
        $this->reflectionProperty->setValue($object, $value);
120✔
36
    }
37

38
    public function isInitialized(object $object): bool
196✔
39
    {
40
        return $this->reflectionProperty->isInitialized($object);
196✔
41
    }
42

UNCOV
43
    public function accepts(mixed $input): bool
×
44
    {
UNCOV
45
        return $this->getType()->accepts($input);
×
46
    }
47

48
    public function getClass(): ClassReflector
90✔
49
    {
50
        return new ClassReflector($this->reflectionProperty->getDeclaringClass());
90✔
51
    }
52

53
    public function getType(): TypeReflector
222✔
54
    {
55
        return new TypeReflector($this->reflectionProperty);
222✔
56
    }
57

UNCOV
58
    public function isIterable(): bool
×
59
    {
UNCOV
60
        return $this->getType()->isIterable();
×
61
    }
62

63
    public function isPromoted(): bool
79✔
64
    {
65
        return $this->reflectionProperty->isPromoted();
79✔
66
    }
67

68
    public function isNullable(): bool
19✔
69
    {
70
        return $this->getType()->isNullable();
19✔
71
    }
72

UNCOV
73
    public function isPrivate(): bool
×
74
    {
UNCOV
75
        return $this->reflectionProperty->isPrivate();
×
76
    }
77

UNCOV
78
    public function isProtected(): bool
×
79
    {
UNCOV
80
        return $this->reflectionProperty->isProtected();
×
81
    }
82

UNCOV
83
    public function isPublic(): bool
×
84
    {
UNCOV
85
        return $this->reflectionProperty->isPublic();
×
86
    }
87

UNCOV
88
    public function isReadonly(): bool
×
89
    {
UNCOV
90
        return $this->reflectionProperty->isReadOnly();
×
91
    }
92

93
    public function getIterableType(): ?TypeReflector
132✔
94
    {
95
        $doc = $this->reflectionProperty->getDocComment();
132✔
96

97
        if (! $doc) {
132✔
98
            return null;
129✔
99
        }
100

101
        preg_match('/@var ([\\\\\w]+)\[]/', $doc, $match);
74✔
102

103
        if (! isset($match[1])) {
74✔
UNCOV
104
            return null;
×
105
        }
106

107
        return new TypeReflector(ltrim($match[1], '\\'));
74✔
108
    }
109

110
    public function isUninitialized(object $object): bool
46✔
111
    {
112
        return ! $this->reflectionProperty->isInitialized($object);
46✔
113
    }
114

115
    public function isVirtual(): bool
124✔
116
    {
117
        return $this->reflectionProperty->isVirtual();
124✔
118
    }
119

120
    public function unset(object $object): void
21✔
121
    {
122
        unset($object->{$this->getName()});
21✔
123
    }
124

125
    public function set(object $object, mixed $value): void
120✔
126
    {
127
        $this->reflectionProperty->setValue($object, $value);
120✔
128
    }
129

130
    public function get(object $object, mixed $default = null): mixed
29✔
131
    {
132
        try {
133
            return $this->reflectionProperty->getValue($object) ?? $default;
29✔
134
        } catch (Error $error) { // @mago-expect best-practices/dont-catch-error
17✔
135
            return $default ?? throw $error;
17✔
136
        }
137
    }
138

139
    public function getName(): string
148✔
140
    {
141
        return $this->reflectionProperty->getName();
148✔
142
    }
143

144
    public function hasDefaultValue(): bool
79✔
145
    {
146
        $constructorParameters = [];
79✔
147

148
        foreach ($this->getClass()->getConstructor()?->getParameters() ?? [] as $parameter) {
79✔
149
            $constructorParameters[$parameter->getName()] = $parameter;
17✔
150
        }
151

152
        $hasDefaultValue = $this->reflectionProperty->hasDefaultValue();
79✔
153

154
        $hasPromotedDefaultValue = $this->isPromoted() && $constructorParameters[$this->getName()]->isDefaultValueAvailable();
79✔
155

156
        return $hasDefaultValue || $hasPromotedDefaultValue;
79✔
157
    }
158
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc