Steve Grunwell on PHP Namespaces for WordPress
I’ve written here on WPShout about PHP namespaces before. But that article is old, and lacks among other things the fun expanding brain meme that our friend Steve Grunwell included in his post. Steve’s post has other reasons to recommend it, aside from the dope meme game.
For one, much more than when I first wrote our post here three years ago, it’s possible for a WordPress developer to use PHP namespaces for WordPress, and not just on one-off client projects where you control the hosting. That transition to more-modern PHPs is a big and important step for us, and great opportunity for developers to up their PHP game.
Also, Steve’s post has everything. He’s a really smart guy, and I loved and recognized this bit about why most WordPress PHP lacks use of real namespaces:
The second group of developers recognized that these plugins were rarely being handled as true objects, instead being used as pseudo-namespaces — constructs to encapsulate code from global namespace collisions without using true PHP namespaces. However, since WordPress still (at the time of this writing) supports PHP 5.2 (which lacks PHP namespace support), developers trying to reach the broadest possible audience still needed a way to reasonably encapsulate their code without relying on (or having to learn, depending on who you ask) PHP namespaces.