smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.22k stars 701 forks source link

Support nullsafe operator #1015

Open SlowFox71 opened 2 months ago

SlowFox71 commented 2 months ago

PHP supports the nullsafe operator ?-> since version 8, so it would be fine, if this were reflected in Smarty as well. A rather simple patch should suffice, see attachment (but I am not a parser expert, as in the suggestions a couple of days ago).

patch.txt

SlowFox71 commented 1 month ago

More thought needs to put into this. For one thing, the patch above is wrong: The lexer needs to be touched, too as otherwise whitespace would be permitted ? -> which is wrong; this is corrected by using the files attached here.

The other thing is that I did not consider registered objects, which I should have done. However, this needs changes in ObjectMethodCallCompiler.php which is beyond my confidence. lexer.txt parser.txt

wisskid commented 1 month ago

Also see #633 and the related PR