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

tempestphp / tempest-framework / 14024978163

23 Mar 2025 05:55PM UTC coverage: 79.391% (-0.05%) from 79.441%
14024978163

push

github

web-flow
feat(view): cache Blade and Twig templates in internal storage (#1061)

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

912 existing lines in 110 files now uncovered.

10478 of 13198 relevant lines covered (79.39%)

91.09 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(
695✔
15
        private PHPReflectionProperty $reflectionProperty,
16
    ) {
17
    }
695✔
18

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

157
        return $hasDefaultValue || $hasPromotedDefaultValue;
79✔
158
    }
159
}
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