Last month I spoke at the Sydney PHP UG about the Active Record design pattern. For the talk I produced an example implementation. While building it the lack of a static version of __call() really stuck out.
Part of the Active Record design pattern is a way to retrieve records where a field matches a given value. Ideally this function would be static and named something like findByXxx(). Without a static version of __call() the you need to choose between implementing a static find() function that takes two parameters or creating an instance of the object so you can take advantage of __call().
I’m sure someone will tell me to just use find($field, $val) but I think that
$user = User::findByUsername('fred');
Looks much cleaner than
$user = User::find('user', 'fred');
or
$user = new User();
$user = $user->findByUsername('fred');
While it’s been 5 years since I last programmed in C I actually feel passionately enough about this to join the PHP internals mailing list and at least investigate what it would take to have this feature added for PHP 5.3. Of course, while this is being added static versions of __get(), __set(), __isset() and __unset() should probably be added too.
This site contains my personal ramblings on Linux, PHP, Java, .NET and anything else that I feel is important.
Hopefully, we now add the __callStatic method