I’ve been working with PHP since 00 and with even longer. Over the last decade, has evolved drastically. It had a promising design from the very beginning and gained its current incredible shape with the shift to ES201 (Harmony). PHP, though, didn’t change that much. Apparently, it’s doomed always to suffer from its own legacy. It arrived in the mid-90s as a simple CGI to maintain Rasmus Lerdorf’s page and have been more like spontaneously developing ever since. That resulted in syntax inconsistency, a mix of functional and OOP-based assets, and absence of a decent language specification. So every time I switch to PHP I miss the rationality, predictability, and flexibility of JavaScript. This made me consider a library which would bring a JavaScript-like development experience to PHP. Eventually, I came up with Extras, which extends PHP types with JavaScript (other than Underscore) , unlocks chaining, and introduces the PlainObject type representing an object-literal.

JavaScript Meets PHP

The library enriches with JavaScript and Underscore.js methods the following PHP types: array (both sequential and associative), string, number (integer, float, NaN), function (callable), collection (Iterable, ArrayObject, Iterator) and boolean. Every added method is a static method of the class representing the type. So we can any directly, without the creation of a chain like Arrays::map.



Source link
thanks you RSS link
( https://dzone.com/articles/javascript-and--type-methods-in-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev)

LEAVE A REPLY

Please enter your comment!
Please enter your name here