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

nette / php-generator / 21808450793

09 Feb 2026 12:39AM UTC coverage: 93.947% (+0.1%) from 93.811%
21808450793

push

github

dg
added CLAUDE.md

1816 of 1933 relevant lines covered (93.95%)

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
 * Definition of a 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
        /** @param \Closure(): mixed $closure */
26
        public static function from(\Closure $closure): self
1✔
27
        {
28
                return (new Factory)->fromFunctionReflection(new \ReflectionFunction($closure));
1✔
29
        }
30

31

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

37

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

49

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

56

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

62

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