Franz Liedke

Master of Science, IT-Systems Engineering
Web developer, Laravel core contributor
Open-source enthusiast, Flarum & FluxBB

A PHP Short Array Syntax Converter

In his PHP Town Hall podcast, Phil Sturgeon mentioned that it would be nice to have an automatic converter for the new short-hand PHP array syntax that was added in PHP 5.4. I agreed, but not that it would be hard to create one. Making use of Symfony’s nice Console package and PHP’s very own tokenizer, it was fairly easy to create.

In fact, the only real issue I faced was making sure that array typehints weren’t removed (as the token parser doesn’t make a difference between array typehints and array definitions). Maybe I have just missed something…

Anyway, you can find the tool here on GitHub. Improvements welcome.