Re: Change yield interpolation behaviour

From: Date: Fri, 08 Oct 2021 11:21:43 +0000
Subject: Re: Change yield interpolation behaviour
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-116251@lists.php.net to get a copy of this message
On 08.10.2021 at 12:57, Kirill Nesmeyanov wrote: > Yes you are right. The same thing happens if you put a function there. > ``` > function hi(): string > { >     return ‘World’; > } >   > echo <<<MSG >     Hello ${hi()} > MSG; > // Warning: Undefined variable $World! > ``` >   > For some reason, I did not take this case into account. >   > Although it seems to me such semantics are old and require removal from the language, I admit > that there is code that uses it and changing the behavior will break a lot. Ideally, I would like to > see a similar behavior: > ``` > echo "Hello ${ $var }"; // Hello World > echo "Hello ${ 'Wo' . 'rld' }"; // same > echo "Foo ${ some_foo(42) }"; > echo "Foo ${ 23 + 42 }";  > echo "Some ${ ClassName::method() >> 2 ?? $any }"; > // etc > ``` See also <https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation>. -- Christoph M. Becker

« previous php.internals (#116251) next »