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

nette / php-generator / 22836119803

09 Mar 2026 02:40AM UTC coverage: 94.264% (+0.2%) from 94.029%
22836119803

push

github

dg
added CLAUDE.md

1890 of 2005 relevant lines covered (94.26%)

0.94 hits per line

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

6.25
/src/PhpGenerator/TraitType.php
1
<?php declare(strict_types=1);
1✔
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
namespace Nette\PhpGenerator;
9

10
use Nette;
11

12

13
/**
14
 * Definition of a trait with properties, methods, constants and traits.
15
 */
16
final class TraitType extends ClassLike
17
{
18
        use Traits\ConstantsAware;
19
        use Traits\MethodsAware;
20
        use Traits\PropertiesAware;
21
        use Traits\TraitsAware;
22

23
        /**
24
         * Adds a member to the trait.
25
         * @throws Nette\InvalidStateException if the member already exists and $overwrite is false
26
         */
27
        public function addMember(Method|Property|Constant|TraitUse $member, bool $overwrite = false): static
28
        {
29
                $name = $member->getName();
×
30
                [$type, $n] = match (true) {
×
31
                        $member instanceof Constant => ['consts', $name],
×
32
                        $member instanceof Method => ['methods', strtolower($name)],
×
33
                        $member instanceof Property => ['properties', $name],
×
34
                        $member instanceof TraitUse => ['traits', $name],
×
35
                };
36
                if (!$overwrite && isset($this->$type[$n])) {
×
37
                        throw new Nette\InvalidStateException("Cannot add member '$name', because it already exists.");
×
38
                }
39
                $this->$type[$n] = $member;
×
40
                return $this;
×
41
        }
42

43

44
        public function __clone(): void
45
        {
46
                parent::__clone();
×
47
                $this->consts = array_map(fn(Constant $c) => clone $c, $this->consts);
×
48
                $this->methods = array_map(fn(Method $m) => clone $m, $this->methods);
×
49
                $this->properties = array_map(fn(Property $p) => clone $p, $this->properties);
×
50
                $this->traits = array_map(fn(TraitUse $t) => clone $t, $this->traits);
×
51
        }
52
}
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