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

nette / php-generator / 15763583786

19 Jun 2025 05:44PM UTC coverage: 91.981% (+0.004%) from 91.977%
15763583786

push

github

dg
optimized global function calls

1755 of 1908 relevant lines covered (91.98%)

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
        /** @internal */
83
        public function setParameters(array $val): static
84
        {
85
                (function (Parameter ...$val) {})(...$val);
×
86
                $this->parameters = [];
×
87
                foreach ($val as $v) {
×
88
                        $this->parameters[$v->getName()] = $v;
×
89
                }
90

91
                return $this;
×
92
        }
93

94

95
        /** @internal */
96
        public function getParameters(): array
97
        {
98
                return $this->parameters;
1✔
99
        }
100

101

102
        /**
103
         * Adds a parameter. If it already exists, it overwrites it.
104
         * @param  string  $name without $
105
         */
106
        public function addParameter(string $name): Parameter
1✔
107
        {
108
                return $this->parameters[$name] = new Parameter($name);
1✔
109
        }
110

111

112
        public function setReturnReference(bool $state = true): static
1✔
113
        {
114
                $this->returnReference = $state;
1✔
115
                return $this;
1✔
116
        }
117

118

119
        public function getReturnReference(): bool
120
        {
121
                return $this->returnReference;
1✔
122
        }
123
}
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