▲ | chuck8088 7 days ago | |||||||
This article makes a great case WHY the pipe operator is useful, but why didn't they just rewrite those functions to support method chaining? ` $profit = [1, 4, 5] .loadSeveral() .filter(isOnSale()) .map(sellWidget()) .array_sum(); ` this has the side benefit of 'looking normal' | ||||||||
▲ | wsatb 7 days ago | parent | next [-] | |||||||
Backwards compatibility. The language has done a pretty amazing job at adding features over the last 10 years without really breaking a lot of old code. I believe PHP still runs about 75% of the internet, so that's pretty huge. | ||||||||
| ||||||||
▲ | troupo 7 days ago | parent | prev [-] | |||||||
Because pipes work on all functions, not just object methods. So your business logic, validations etc. don't have to be methods of the built-in objects. And there's nothing abnormal about pipes |