3 ms·
Interesting concept, the chainable object specially showcases well what PHP is missing by neglecting data types as objects. Makes you wonder whether it could be
by Mahn 14y ago
Interesting concept, the chainable object specially showcases well what PHP is missing by neglecting data types as objects. Makes you wonder whether it could be simplified further though; ie, combining s(), a(), o() and c() into a single one letter function that does it all, jQuery style. I think it'd have a better chance of adoption that way.
- plorkyeran 14y agoYou wouldn't be able to do the JSON stuff and the string wrapping with a single function, but otherwise that could be a good idea.
- Mahn 14y agoWhy not? You could test if the string is valid json, and if it is do object wrapping, otherwise do string wrapping. This method is used often in jQuery, figuring out what to do depending on what you pass to it. EDIT: and I guess a second, optional argument to force a specific data type could be added for those rare cases where you have a json string and you want to run string functions on it.
- tangue 14y agoJquery is a reference for designing a clean API and I suspect (this library aside) many php coders would have liked if php 6 move this way. But php core dev are waaay too conservative.