Hi Nikic, I was wondering if its possible to write an extension for your PHP-Parser library that supports Scalar Objects syntax. It will be able to parse syntax from scalar objects, and it will also be able to transpile between code written with Scalar Objects with code written without Scalar Objects. Anyway here is a simple illustration.
Code with Scalar Objects:
$capLetters = "this is a string"->toUpperCase();
Code without Scalar Objects:
$capLetters = StringObject::toUpperCase("this is a string");
So as you see, the difference is simple that scalar objects extension converts a static call ScalarObject::method($scalar) to $scalar->method(). I think it shouldnt be very difficult, what do you think? Are you interested in making one? Or if possible I can give a try sometime in future when I have more time myself.
Hi Nikic, I was wondering if its possible to write an extension for your PHP-Parser library that supports Scalar Objects syntax. It will be able to parse syntax from scalar objects, and it will also be able to transpile between code written with Scalar Objects with code written without Scalar Objects. Anyway here is a simple illustration.
Code with Scalar Objects:
$capLetters = "this is a string"->toUpperCase();
Code without Scalar Objects:
$capLetters = StringObject::toUpperCase("this is a string");
So as you see, the difference is simple that scalar objects extension converts a static call ScalarObject::method($scalar) to $scalar->method(). I think it shouldnt be very difficult, what do you think? Are you interested in making one? Or if possible I can give a try sometime in future when I have more time myself.