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

nette / php-generator / 9052389242

12 May 2024 03:19PM UTC coverage: 93.686% (-0.1%) from 93.792%
9052389242

push

github

dg
Factory, Extractor: sets flag readonly for promoted properties [Closes #158]

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

5 existing lines in 4 files now uncovered.

1558 of 1663 relevant lines covered (93.69%)

0.94 hits per line

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

45.45
/src/PhpGenerator/InterfaceType.php
1
<?php
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Nette\PhpGenerator;
11

12
use Nette;
13

14

15
/**
16
 * Interface description.
17
 */
18
final class InterfaceType extends ClassLike
19
{
20
        use Traits\ConstantsAware;
21
        use Traits\MethodsAware;
22

23
        /** @var string[] */
24
        private array $extends = [];
25

26

27
        /**
28
         * @param  string|string[]  $names
29
         */
30
        public function setExtends(string|array $names): static
1✔
31
        {
32
                $names = (array) $names;
1✔
33
                $this->validateNames($names);
1✔
34
                $this->extends = $names;
1✔
35
                return $this;
1✔
36
        }
37

38

39
        /** @return string[] */
40
        public function getExtends(): array
41
        {
42
                return $this->extends;
1✔
43
        }
44

45

46
        public function addExtend(string $name): static
1✔
47
        {
48
                $this->validateNames([$name]);
1✔
49
                $this->extends[] = $name;
1✔
50
                return $this;
1✔
51
        }
52

53

54
        /**
55
         * Adds a member. If it already exists, throws an exception or overwrites it if $overwrite is true.
56
         */
57
        public function addMember(Method|Constant $member, bool $overwrite = false): static
58
        {
59
                $name = $member->getName();
×
60
                [$type, $n] = match (true) {
×
61
                        $member instanceof Constant => ['consts', $name],
×
62
                        $member instanceof Method => ['methods', strtolower($name)],
×
63
                };
64
                if (!$overwrite && isset($this->$type[$n])) {
×
65
                        throw new Nette\InvalidStateException("Cannot add member '$name', because it already exists.");
×
66
                }
67
                $this->$type[$n] = $member;
×
68
                return $this;
×
69
        }
70

71

72
        public function __clone(): void
73
        {
74
                parent::__clone();
×
75
                $clone = fn($item) => clone $item;
×
76
                $this->consts = array_map($clone, $this->consts);
×
UNCOV
77
                $this->methods = array_map($clone, $this->methods);
×
78
        }
79
}
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

© 2025 Coveralls, Inc