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

nette / php-generator / 8833786024

25 Apr 2024 01:47PM UTC coverage: 93.784% (+0.02%) from 93.769%
8833786024

push

github

dg
added PhpFile::removeNamespace()

4 of 4 new or added lines in 1 file covered. (100.0%)

24 existing lines in 6 files now uncovered.

1539 of 1641 relevant lines covered (93.78%)

0.94 hits per line

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

0.0
/src/PhpGenerator/TraitType.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
 * Trait description.
17
 */
18
final class TraitType extends ClassLike
19
{
20
        use Traits\ConstantsAware;
21
        use Traits\MethodsAware;
22
        use Traits\PropertiesAware;
23
        use Traits\TraitsAware;
24

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

44

45
        public function __clone()
46
        {
47
                $clone = fn($item) => clone $item;
×
48
                $this->consts = array_map($clone, $this->consts);
×
UNCOV
49
                $this->methods = array_map($clone, $this->methods);
×
UNCOV
50
                $this->properties = array_map($clone, $this->properties);
×
UNCOV
51
                $this->traits = array_map($clone, $this->traits);
×
52
        }
53
}
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