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

nette / php-generator / 16783678748

06 Aug 2025 05:10PM UTC coverage: 92.006%. Remained the same
16783678748

push

github

dg
small fixes

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

6 existing lines in 4 files now uncovered.

1761 of 1914 relevant lines covered (92.01%)

0.92 hits per line

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

82.14
/src/PhpGenerator/PropertyHook.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Nette\PhpGenerator;
6

7
use JetBrains\PhpStorm\Language;
8

9

10
/**
11
 * Definition of a property hook.
12
 */
13
final class PropertyHook
14
{
15
        use Traits\AttributeAware;
16
        use Traits\CommentAware;
17

18
        private string $body = '';
19
        private bool $short = false;
20
        private bool $final = false;
21
        private bool $abstract = false;
22

23
        /** @var Parameter[] */
24
        private array $parameters = [];
25
        private bool $returnReference = false;
26

27

28
        /** @param  ?mixed[]  $args */
29
        public function setBody(
1✔
30
                #[Language('PHP')]
31
                string $code,
32
                ?array $args = null,
33
                bool $short = false,
34
        ): static
35
        {
36
                $this->body = $args === null
1✔
37
                        ? $code
1✔
38
                        : (new Dumper)->format($code, ...$args);
1✔
39
                $this->short = $short;
1✔
40
                return $this;
1✔
41
        }
42

43

44
        public function getBody(): string
45
        {
46
                return $this->body;
1✔
47
        }
48

49

50
        public function isShort(): bool
51
        {
52
                return $this->short && trim($this->body) !== '';
1✔
53
        }
54

55

56
        public function setFinal(bool $state = true): static
1✔
57
        {
58
                $this->final = $state;
1✔
59
                return $this;
1✔
60
        }
61

62

63
        public function isFinal(): bool
64
        {
65
                return $this->final;
1✔
66
        }
67

68

69
        public function setAbstract(bool $state = true): static
1✔
70
        {
71
                $this->abstract = $state;
1✔
72
                return $this;
1✔
73
        }
74

75

76
        public function isAbstract(): bool
77
        {
78
                return $this->abstract;
1✔
79
        }
80

81

82
        /**
83
         * @param  Parameter[]  $val
84
         * @internal
85
         */
86
        public function setParameters(array $val): static
87
        {
88
                (function (Parameter ...$val) {})(...$val);
×
UNCOV
89
                $this->parameters = [];
×
UNCOV
90
                foreach ($val as $v) {
×
91
                        $this->parameters[$v->getName()] = $v;
×
92
                }
93

UNCOV
94
                return $this;
×
95
        }
96

97

98
        /**
99
         * @return  Parameter[]
100
         * @internal
101
         */
102
        public function getParameters(): array
103
        {
104
                return $this->parameters;
1✔
105
        }
106

107

108
        /**
109
         * Adds a parameter. If it already exists, it overwrites it.
110
         * @param  string  $name without $
111
         */
112
        public function addParameter(string $name): Parameter
1✔
113
        {
114
                return $this->parameters[$name] = new Parameter($name);
1✔
115
        }
116

117

118
        public function setReturnReference(bool $state = true): static
1✔
119
        {
120
                $this->returnReference = $state;
1✔
121
                return $this;
1✔
122
        }
123

124

125
        public function getReturnReference(): bool
126
        {
127
                return $this->returnReference;
1✔
128
        }
129
}
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