Leider ist der Beitrag nur auf Englisch verfügbar.
3 Replies to “Collection Pipelines in PHP”
Comments are closed.
Dipl. Inform. Fabian Schmengler | Magento Certified Developer | Magento Certified Solution Specialist
Leider ist der Beitrag nur auf Englisch verfügbar.
Comments are closed.
Leider ist der Beitrag nur auf Englisch verfügbar.
The problem with inventing new facilities is everyone ends up either making their own, or using one of many different available libraries – you end up with code that isn’t very idiomatic, you increase complexity, introduce new dependencies, add to the learning curve, etc.
The horrible inside-out examples you show with the array_() functions of course isn’t the only possible workflow with these – you can have a linear workflow by introducing an intermediary variable, I posted an example and some quick notes here:
https://gist.github.com/mindplay-dk/4ef61fd5c0a35e5aa8fc699febb86487
Thank you for the example, I like it. It’s probably the best you can get with “idiomatic PHP” and I get your point of not introducing new dependencies or reinventing “foreign” concepts. For this example I cannot even argue against the temporary variable.
It is a fine line between actual improvement and unnecessary complexity.
Just to add yet another library in the mix, have a look at my enumerable lib ( https://packagist.org/packages/lasso3000/enumerable ). It tries to stay close to ruby’s Enumerable module and the main difference from Knapsack is that the functionality is attached using a trait instead of a specialized class. The main benefit of that approach is that *any* class can be an Enumerable (just like in ruby).