[PHP] Strict error on static call? Solved!
Just a quick post about Strict standard error when we have a class method which would like to behave differently if called statically. Apparently, and this is a truly old bogus I opened ages ago , the solution was to supress Strict errors (lol, thanks developers) even if in every other programming language, via overload, this kind of situation could be solved in a bit. How to solve the problem? While last post I suggested a couple of runtime solutions, this time I suggest to simply avoid the method definition and use a different one with a meaningful name. In this example I created a String class: class String { // choose a recognizable name for protected method static protected function _concat(array $arguments){ return new self(implode('', $arguments)); } // use magic __callStatic function static public function __callStatic($name, array $arguments){ // check the recognizable name switch($name = '_'.$name){ ...