public static vs static public
Ever since starting with PHP 5 object oriented development, all documentation I read on the topic seemed to suggest that the only way to write the method keywords is "public static". I've been following along those lines, and for a while I really thought any other order would trigger errors. Only recently I found out the other way round is actually nicer.
Even in current literature on PHP 5 object oriented development, you'll mostly see mentions of the "public static" order. And it isn't strange, I can understand that some people prefer the PPP at the start to give clarity on the access rules for methods.
While looking around inside the symfony code, I first encountered the "static public" order of keywords. At first, I thought this strange, but the more I look at it, the more beautiful I think it is. It gives a great overview of which methods are static and which aren't.
In the end it is of course a personal preference, however I've found my preference shifting towards the latter over the past months. I decided to check which was preferred most in my twitterverse, and here's the results:

As you can see, a big majority still prefers "public static". However, even more important I think is that the "static public" had more ground than I expected (or perhaps it's that a lot of people that follow me come from the symfony world). Having 2 votes for the option "I don't use static methods" was perhaps also a small surprise, but I guess it depends a lot on what you work on as well.
If you haven't voted yet, feel free to give your opinion in my poll.
January 26, 2009 - tags: php, static, public, symfony
Comments
Jan Schneider: A bit more representative, but somehow similar numbers: Google Code Search gives 45000 to 10200 for "public static" vs. "static public".
Evert: Funny! I've been wondering about the same thing.
My codebase:
public static = 2
static public = 12
Sara Golemon: My personal preference is 'public static', but I'm not strict about it, and I don't have it included in my project's coding standards.
Stats:
49.4% public static
34.1% static public
9.0% protected static
3.8% static protected
2.0% private static
1.6% static keyword only (implicit public)
0.1% final public static (a personal favorite)
Alvaro Videla: I voted for the public static just because is what I'm used to it. There is a new PHP developer on our time that came from the JAVA land and all his static methods are static public ... So know, depending on which classes I work, is the style I pick.
cx42net: I think the most important is not to write in a manner on in an other one, but to stick with one of it.
Like Alvaro Videla said, it's all about coding standards.
You cannot have your class written with a part starting by "public static" and the rest starting by "static public", it's so non professionnal !
PiccoloPrincipe: I prefer not to use static methods, that seems like more procedural than OOP.

uli: @PiccoloPrincipe:
so, how can you be able to implement design patterns such as the singleton pattern without static methods and members? Not for nothing every oo language has this language construct.
Nick Belhomme: I prefer
public static function. I always put my static functions in the top of the class.
But Maybe I should switch as when I see static public, it gives more clarity. But then again habits die slow()
Nick
Perry: I think for most programmers they will be akin to the "public static" declaration. In C++ when you are defining classes, you place the "public:" before any variable/function declarations, eg:
public:
static int x;
char *ptr;
Keeping the public in front of the static gives you a more "cross language" discipline in my opinion.

Foo: I don't use public

since a member is per default public.
Then you immediately see that a member is static or not.
Paul Davis: @uli
"so, how can you be able to implement design patterns such as the singleton pattern without static methods and members?"
The only static method in a Singleton should be the one that gives you the instance. None of the other methods should be static.
If so, you are not implementing a Singleton, you're just creating a class with static methods.
Even then, the singleton doesn't necessarily need to have a static instance method, the singleton could also be provided by a factory class, in which case, the singleton would have no static methods (or even be aware that it is a singleton).
left: Foo: even when a method or property is per default public, I think it is good practice to explicitly define it as public. That makes your code more clear. If you omit the 'public' part, then it might also be that you've forgotten to specify the access rules to the said property or method. However, when you explicitly state it to be public, you for sure know that it is public and is meant that way.
Paul Davis: It would be very hard to implement a singleton without at least the getInstance() method which should be static. Your factory can only extend a single class, making it a bit of a useless factory (as it would only be able to "produce" a single class instance) - unless of course the other classes are not singletons. Or am I overlooking another way to do singleton?
cx42net: Paul Davis: And in the case that you use a Factory pattern instead of a Singleton pattern, the Factory should also implement static method (at least one).
You cannot ignore using static methods. Java have static method, .Net framework have static method. In fact, all frameworks uses, somewhere, static methods.
Yes, for sure, you can use static method in class in kind of namespace for Php < 5.3, but if the "static" way is always present is OOP mean that it is important.
PiccoloPrincipe: @cx42net, @uli:
As a TDDer, I try to not use singleton as they carry global state trought the application. This aids decoupling and test in isolation of classes. If a class use a singleton, it lies about its dependencies since it access other objects that are not passed to it in the constructor; moreover,you can't mock out the implementation for unit testing.
(search Dependency injection on google for further explanation, or the google testing blog)
Johny: is there any difference between ?
I would say static first, cause static is the more important property,
cause property to mark it is callable outside context,
but i think i used both ways in past cause i am always thinking which is the more important one.

ruisilva: I've the same reaction as you when i look at symfony code.
static public looks better.
write proposals: Thank You for unique information!
online dating sites: you, what expertise do you have on this issue? Make us laugh a little! Already when I read your initial reactions, I feel we are in a good way to big lol!
paxil lawsuit: The development is so good behind this is so much. There is so much that you can get from this. Keep up the good work.
Cruise deals: I see so much that you can do with it. I see a great future from using this. I see so many great things coming from this.
buy research papers: That's exactly what I was looking for! Your article is much useful for my paper, thanks a lot
essay writing guide: Boredom flourishes too, when you feel safe. It's a symptom of security.
weight loss: The war between being and nothingness is the underlying illness of the twentieth century. Boredom slays more of existence than war.
Ugg Boots Sale: It gives a great overview of which methods are static and which aren't.
gwswfm: I prefer not to use static methods, that seems like more procedural than OOP.
free screensavers fishes: Completely FREE screen savers for Windows. We have handpicked and tested some of the best free screensavers around: no expiry, no nag messages, Screen savers and wallpapers for Windows and Mac including OS X. Collections consist of images from artists and photographers.
discount uggs boots: I am typically to running a blog and i really respect your content. The article has really peaks my interest.
michael kors purses: I am absolutely amazed at how terrific the stuff is on this site. I have saved this webpage and I truly intend on visiting the site in the upcoming days. Keep up the excellent work!
IT Support Firgrove: These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post