Letter to Santa from PHP developer

Mantas Donelavicius
2 min readDec 17, 2017

Hello Santa,

This year I was a good boy. I haven’t tested code in production. Tried to fix bugs as fast as they arise and not leaving them for later. I have crashed the server only once!

Recently I saw a boy named Java who was playing with a new hot toy — Short Closures. I asked my parents to buy it. But unfortunately in our city this toy isn’t available yet.

So I put a little elbow grease and from sticks and duct tape I made a similar thing for PHP. I know that not every boy saw this new toy yet, so let me tell you a bit more about it.

When Short Closures are useful?

If you have watched Adam Wathan talk on YouTube there he is refactoring code from loops to collections. His final code looks like this:

To me it is still not good enough. Probably that’s why I rarely write it like so. The main problem is that code is cluttered with anonymous function syntax. This syntax doesn’t add any value to code readability. What if we could use Short Closures in PHP?

That would be nice, right?

Actually I have created a small library to show that it is possible: https://github.com/mantas-done/short-closures

I don’t want much this year for Christmas. My only wish is that every year would be a bit easier for every developer than the previous one. I heard that some of them aren’t making much and probably are starving. If you can, bring them some vegetables, because some say that eating “spaghetti” is not very healthy. And about this new toy and my wishlist Santa, if you really really exist, I would really want:

  1. Implementation of my proposed library in Laravel Collection
  2. Implementation of real short closures in PHP

Yours good boy,
Mantas

--

--