News for hackers. Stuff that matters.
Re:PHP: The Right Way by ObnoxiousJul on Saturday July 07, 2012 @08:31PM (#4213152)
Right way to write PHP indeed. Sometimes I wish PHP itself was written this way.

Oh! The guide does not mention the case: if a class contains only one static method, please, use a function. It does not look as educated, but it's obviously a function.

Not PHP specific, I admit.

Re:PHP: The Right Way by ChiperSoft on Saturday July 07, 2012 @10:39PM (#4213392)
Perhaps I'm misunderstanding what you're saying, but standalone functions cannot be namespaced or autoloaded. Static methods solve both of these problems. With late static binding there's no reason to avoid static methods any more.
Re:PHP: The Right Way by lotyrin on Saturday July 07, 2012 @10:23PM (#4213362)
Oh god yes. I ran into an extreme case of this recently. 200 something lines of class definition, class variables and internal private methods that end up chaining 5-deep, with a single public method.

Refactoring to a single function took it down to under 20 lines.

I wish I knew what motivated people to do things like this.

Re:PHP: The Right Way by FuzzyDunlop on Sunday July 08, 2012 @04:34PM (#4215616)
From my own experience, PHP developers who are introduced to OOP often get taught the Java-esque flavour of it. Classes for everything, abstractions and base classes and inheritance all over the place.

Hell, I even went there myself at one point, at first doing it to DRY up a bunch of procedural scripts, but later introducing more abstractions to bend the existing code to my will.

Now, I prefer simplicity and will often scrap code that jumps through all sorts of hoops just to do something simple.

Re:PHP: The Right Way by etherealG on Sunday July 08, 2012 @05:09AM (#4214150)
pretty sure it's the same thing every time: coming from working on really big systems that need that much depth of abstraction to something simple that can be done in 20 lines and forgetting, or not understanding how to scale down. most common with c# or java coders doing client libs for php for their application.
Re:PHP: The Right Way by mgkimsal on Saturday July 07, 2012 @10:20PM (#4213349)
It would depend on what else is in the class - descriptive class constants used by the one static method wouldn't be possible if it was 'just a function'.