|
14 | 14 | * @psalm-template BType
|
15 | 15 | * @psalm-template CType
|
16 | 16 | * @psalm-template DType
|
| 17 | + * |
| 18 | + * @psalm-immutable |
17 | 19 | */
|
18 | 20 | final class D extends Combinator
|
19 | 21 | {
|
20 | 22 | /**
|
| 23 | + * @psalm-var callable(AType): callable(CType): DType |
| 24 | + * |
21 | 25 | * @var callable
|
22 | 26 | */
|
23 |
| - private $f; |
| 27 | + private $a; |
24 | 28 |
|
25 | 29 | /**
|
26 |
| - * @var callable |
| 30 | + * @psalm-var AType |
| 31 | + * |
| 32 | + * @var mixed |
27 | 33 | */
|
28 |
| - private $g; |
| 34 | + private $b; |
29 | 35 |
|
30 | 36 | /**
|
31 |
| - * @var mixed |
| 37 | + * @psalm-var callable(BType): CType |
| 38 | + * |
| 39 | + * @var callable |
32 | 40 | */
|
33 |
| - private $x; |
| 41 | + private $c; |
34 | 42 |
|
35 | 43 | /**
|
| 44 | + * @psalm-var BType |
| 45 | + * |
36 | 46 | * @var mixed
|
37 | 47 | */
|
38 |
| - private $y; |
| 48 | + private $d; |
39 | 49 |
|
40 | 50 | /**
|
41 | 51 | * D constructor.
|
42 | 52 | *
|
43 |
| - * @psalm-param callable(AType): callable(CType): DType $f |
44 |
| - * @psalm-param AType $x |
45 |
| - * @psalm-param callable(BType): CType $g |
46 |
| - * @psalm-param BType $y |
| 53 | + * @psalm-param callable(AType): callable(CType): DType $a |
| 54 | + * @psalm-param AType $b |
| 55 | + * @psalm-param callable(BType): CType $c |
| 56 | + * @psalm-param BType $d |
47 | 57 | *
|
48 |
| - * @param callable $f |
49 |
| - * @param callable $g |
50 |
| - * @param mixed $x |
51 |
| - * @param mixed $y |
| 58 | + * @param callable $a |
| 59 | + * @param mixed $b |
| 60 | + * @param callable $c |
| 61 | + * @param mixed $d |
52 | 62 | */
|
53 |
| - public function __construct(callable $f, $x, callable $g, $y) |
| 63 | + public function __construct(callable $a, $b, callable $c, $d) |
54 | 64 | {
|
55 |
| - $this->f = $f; |
56 |
| - $this->x = $x; |
57 |
| - $this->g = $g; |
58 |
| - $this->y = $y; |
| 65 | + $this->a = $a; |
| 66 | + $this->b = $b; |
| 67 | + $this->c = $c; |
| 68 | + $this->d = $d; |
59 | 69 | }
|
60 | 70 |
|
61 | 71 | /**
|
62 | 72 | * @psalm-return DType
|
63 | 73 | */
|
64 | 74 | public function __invoke()
|
65 | 75 | {
|
66 |
| - return (($this->f)($this->x))(($this->g)($this->y)); |
| 76 | + return (($this->a)($this->b))(($this->c)($this->d)); |
67 | 77 | }
|
68 | 78 |
|
69 | 79 | /**
|
70 |
| - * @param callable $a |
| 80 | + * @template NewAType |
| 81 | + * @template NewBType |
| 82 | + * @template NewCType |
| 83 | + * @template NewDType |
| 84 | + * |
| 85 | + * @psalm-param callable(NewAType): callable(NewCType): NewDType $f |
| 86 | + * |
| 87 | + * @param callable(NewCType): NewDType $f |
71 | 88 | *
|
72 |
| - * @return Closure |
| 89 | + * @return Closure(NewAType): Closure(Closure(NewBType): NewCType): Closure(NewBType): NewDType |
73 | 90 | */
|
74 |
| - public static function on(callable $a): Closure |
| 91 | + public static function on(callable $f): Closure |
75 | 92 | {
|
76 |
| - return static function ($b) use ($a): Closure { |
77 |
| - return static function (callable $c) use ($a, $b): Closure { |
78 |
| - return static function ($d) use ($a, $b, $c) { |
79 |
| - return (new self($a, $b, $c, $d))(); |
80 |
| - }; |
| 93 | + return |
| 94 | + /** @param NewAType $x */ |
| 95 | + static function ($x) use ($f): Closure { |
| 96 | + return |
| 97 | + /** @param callable(NewBType): NewCType $g */ |
| 98 | + static function (callable $g) use ($f, $x): Closure { |
| 99 | + return |
| 100 | + /** @param NewBType $y */ |
| 101 | + static function ($y) use ($f, $x, $g) { |
| 102 | + return (new self($f, $x, $g, $y))(); |
| 103 | + }; |
| 104 | + }; |
81 | 105 | };
|
82 |
| - }; |
83 | 106 | }
|
84 | 107 | }
|
0 commit comments