Re: [RFC][Under discussion] Arbitrary string interpolation

From: Date: Mon, 28 Mar 2022 13:22:22 +0000
Subject: Re: [RFC][Under discussion] Arbitrary string interpolation
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-117438@lists.php.net to get a copy of this message
Hi, > A large part of that is because the placeholders are positional rather > > than named, so you have to keep track of which is which; but by the time > > you've got named placeholders, you might as well have variable > > interpolation. > > I feel the same way. PHPStorm has a feature that highlights the given > expression when your cursor is placed on a %s placeholder and vice > versa. This seems to be the treatment of that symptom. > Has "add named placeholders to *printf()" been proposed/discussed before (I didn't find)? What about strtr() (e.g. `strtr('The {foo} is {bar}.', ['{foo}' => FOO, '{bar}' => bar()])`)? (and even templating engines like Twig?) Anyway, it sometimes baffles me indeed that I can build a string with a method call like "...{$foo->bar()}..." but not with a function call like "...{foo($bar)}...", and also with complex interpolation via callable variable like "...{$foo($bar + baz($qux))}..." but not with simple constant like "...{FOO}..." or operation like "...{$foo + 1}..." :/ Regards, -- Guilliam Xavier

« previous php.internals (#117438) next »