mrkrstphr

mrkrstphr's blog

twitter github

PHP Pulls: Freeing Reserved Words for Use?

Posted on 12 Sep 2013

A developer named bwoebi has submitted a pull request to PHP that would allow - in certain circumstances - previously reserved words to be used as class and method names.

His example shows a class named List with a method of default().

This would be pretty sweet and has been, at times, something that has frustrated me when I've wanted a method called something like list, but had to go with getList() instead due to list being a reserved word.

The only problem with this implementation is that it leads to a lot of ambiguity and unintended consequences, such as writing a function named list and then not knowing if the one should call the built-in list or the user function.

I'm very interested to see where this goes. I'd definitely support it in the case of Class and Method names.

cleanphp

The Clean Architecture in PHP

I've written a book on the Clean Architecture in PHP, which covers how to cleanly organize and decouple your code in a way that prepares it to survive and be easy to maintain for the long term.

Check it out!