Object Overloading in PHP5
August 7th, 2007 : Austin SmithOne of my biggest complaints about PHP5 is that you can’t do genuine object overloading, you can only fake it using the __call() method and its brethren. The crappy part about __call() is that if you want to do anything complex, you end up reinventing the wheel in a big if, elseif… else block, or maybe a switch statement. It’s not well suited for real overloading, Java style. We’re better off just using func_get_args() at the top of a method and choosing different paths based on what we find in the function arguments. But that too can get overwhelming. I thought of a solution which I find interesting. I’m not saying it’s right, or even a good idea, but it comes as close to real overloading as anything, is quick enough to use, and demands strict variable typing. Read the rest of this entry »
Tags:Development Interesting languages Object Oriented Programming PHP typing




