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

nette / php-generator / 9052482594

12 May 2024 03:36PM UTC coverage: 93.566% (-0.1%) from 93.686%
9052482594

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%)

4 existing lines in 3 files now uncovered.

1556 of 1663 relevant lines covered (93.57%)

0.94 hits per line

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

90.91
/src/PhpGenerator/Closure.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

13
/**
14
 * Closure.
15
 */
16
final class Closure
17
{
18
        use Traits\FunctionLike;
19
        use Traits\AttributeAware;
20

21
        /** @var Parameter[] */
22
        private array $uses = [];
23

24

25
        public static function from(\Closure $closure): self
1✔
26
        {
27
                return (new Factory)->fromFunctionReflection(new \ReflectionFunction($closure));
1✔
28
        }
29

30

31
        public function __toString(): string
32
        {
33
                return (new Printer)->printClosure($this);
1✔
34
        }
35

36

37
        /**
38
         * Replaces all uses.
39
         * @param  Parameter[]  $uses
40
         */
41
        public function setUses(array $uses): static
1✔
42
        {
43
                (function (Parameter ...$uses) {})(...$uses);
1✔
44
                $this->uses = $uses;
1✔
45
                return $this;
1✔
46
        }
47

48

49
        /** @return Parameter[] */
50
        public function getUses(): array
51
        {
52
                return $this->uses;
1✔
53
        }
54

55

56
        public function addUse(string $name): Parameter
1✔
57
        {
58
                return $this->uses[] = new Parameter($name);
1✔
59
        }
60

61

62
        public function __clone(): void
63
        {
UNCOV
64
                $this->parameters = array_map(fn($param) => clone $param, $this->parameters);
×
65
        }
66
}
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