You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/documentation/php-interop.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,13 +55,24 @@ Evaluates `expr` and creates a new PHP class using the arguments. The instance o
55
55
56
56
Calls a method or property on a PHP object. Both `methodname` and `property` must be symbols and cannot be an evaluated value.
57
57
58
+
You can chain multiple method calls or property accesses in one `php/->` expression. Each element is evaluated sequentially on the result of the previous call, allowing fluent-style interactions or access to nested properties.
59
+
58
60
```phel
59
61
(ns my\module)
60
62
61
63
(def di (php/new \DateInterval "PT30S"))
62
64
63
65
(php/-> di (format "%s seconds")) # Evaluates to "30 seconds"
64
66
(php/-> di s) # Evaluates to 30
67
+
68
+
# Chain multiple calls:
69
+
# (new DateTimeImmutable("2024-03-10"))->modify("+1 day")->format("Y-m-d")
70
+
(php/-> (php/new \DateTimeImmutable "2024-03-10")
71
+
(modify "+1 day")
72
+
(format "Y-m-d"))
73
+
74
+
# Mix methods and properties: $user->profile->getDisplayName()
0 commit comments