As a full-stack web developer I spend a lot of time switching between back-end and front-end code. When you’ve been working in TypeScript or JavaScript ES6, coming back to PHP and it’s lack of short form for anonymous functions and closures is a real frustration.

Image of TypeScript closure code

TypeScript closure

Image of PHP closure code

PHP Closure

Whilst we all continue to wait for the progress of the PHP RFC for arrow functions, fortunately there are some tricks you can use to make it a lot less painful for creating these functions in PHP.
(Continue reading…)