We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f59919 commit 2cbd440Copy full SHA for 2cbd440
Zend/tests/closure_composition/invokable.phpt
@@ -0,0 +1,27 @@
1
+--TEST--
2
+Invokable objects may be composed
3
+--FILE--
4
+<?php
5
+
6
+class Times {
7
+ public function __construct(private int $x) {}
8
9
+ public function __invoke(int $y): int
10
+ {
11
+ return $this->x * $y;
12
+ }
13
+}
14
15
+function double(int $x): int {
16
+ return $x * 2;
17
18
19
+$cb1 = double(...) + new Times(3);
20
+var_dump($cb1(4));
21
22
+$cb2 = new Times(3) + double(...);
23
+var_dump($cb2(4));
24
25
+--EXPECT--
26
+int(24)
27
0 commit comments