Closed camsjams closed 8 years ago
We could replace \Handlebars\String
with \Handlebars\UnsafeString
to play nice with PHP7 but it can break backward compatibility. What do you think @fzerorubigd ?
We can just check the php version and load a different class. And to avoid maintaining duplicate code, either they can both inherit from one class or we can use traits.
Even simpler: We can have \Handlebars\UnsafeString
as main implementation just like you suggested and extend \Handlebars\String
from it (making it deprecated). Nothing else is required for this as php 7 users will stick to \Handlebars\UnsafeString
and others will continue using \Handlebars\String
.
@everplays the second option (about inheritance) you've proposed could be the way to go. I'll try to implement a PR for that soon.
Actually the situation is more complicated than I thought before. Here \Handlebars\String
is used to wrap template contents. Do we need one more string class (lets say \Handlebars\TemplateString
) for such usage?
@JustBlackBird this part should be checked with an if
statement. If the version is 7, only check against UnsafeString
. Otherwise, both UnsafeString
and String
.
Could you please release a new version containing #135 ?
Thanks!
I just tagged v0.10.3
. Enjoy.
Thank you! PHP 7 here we come! :)
This library doesn't work in PHP 7 = Cannot use Handlebars\String as String because 'String' is a special class name.