• 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

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

11
/**
12
 * Definition of a closure.
13
 */
14
final class Closure
15
{
16
        use Traits\FunctionLike;
17
        use Traits\AttributeAware;
18

19
        /** @var list<Parameter> */
20
        private array $uses = [];
21

22

23
        /**
24
         * Creates an instance from a closure reflection.
25
         * @param  \Closure(): mixed  $closure
26
         */
27
        public static function from(\Closure $closure): self
1✔
28
        {
29
                return (new Factory)->fromFunctionReflection(new \ReflectionFunction($closure));
1✔
30
        }
31

32

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

38

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

50

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

57

58
        /**
59
         * Adds a variable binding to the closure's use list.
60
         */
61
        public function addUse(string $name): Parameter
1✔
62
        {
63
                return $this->uses[] = new Parameter($name);
1✔
64
        }
65

66

67
        public function __clone(): void
68
        {
69
                $this->parameters = array_map(fn($param) => clone $param, $this->parameters);
×
70
        }
71
}
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