nikic / scalar_objects

Extension that adds support for method calls on primitive types in PHP
MIT License
1.13k stars 44 forks source link

Scalar objects(PHP 7) does not support string interpolation? #29

Closed HallofFamer closed 8 years ago

HallofFamer commented 8 years ago

It seems that in the PHP 7 version for Scalar Objects, it is now possible to do something like "str"->toUpper(). It is very nice, but I find that string interpolation wont work. So the code below will fail:

$filepath = "{$path}/{$class}.php"->toLower();

Is this the expected behavior, or is it a glitch? Just wondering.

nikic commented 8 years ago

This is a bug in PHP (or at least an oversight). I've reported it upstream as https://bugs.php.net/bug.php?id=72981. For now a workaround is ("{$path}/{$class}.php")->toLower();.