Nullsafe object operator #1181
santaclaus21
started this conversation in
General
Replies: 1 comment
-
|
Work has been done in 2024 on this: #860 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a nullsafe operator in Smarty similar to PHP's ?->?
In PHP 8 we can safely access properties or call methods on objects that may be null using the nullsafe operator, for example:
{$user?->getAddress()?->getCity()}
However, when working with Smarty templates, accessing nested object properties seems to require additional checks to avoid errors if one of the objects is null.
Is there an equivalent mechanism in Smarty, or a recommended way to handle this case?
(related: #633)
Beta Was this translation helpful? Give feedback.
All reactions