Which convention is more common “static public function” or “public static function” (based on Symfony and Doctrine)

Few minutes ago Brent Shaffer asked on the Twitter

Which is more standard, “public static function” or “static public function”?

I was curious about it, so I’ve checked which convention is used in my favourite Symfony Project. Of course, I haven’t got enough time to check it manually, class by class, so I wrote simple bash script:

egrep "^[^\*/]*static.*function" /usr/share/php/symfony/ -rioh --include=*.php | sed 's/^\s*//g' | sort | uniq  -c | sort -r

The answer  for the Symfony 1.2 was:

685 public static function
181 static public function
27 static protected function
16 protected static function
16 private static function
11 static function
2 abstract public static function

I’ve done same thing for Doctrine ORM Project

egrep "^[^\*/]*static.*function" /usr/share/php/Doctrine/lib/ -rioh --include=*.php | sed 's/^\s*//g' | sort | uniq  -c | sort -r

and the result was:

78 public static function
6 static public function
6 static protected function

Now I can tell that “public static function” is more common, and by the way I use same convention in my classes :-)

Read more

wigwam.sh – pobieranie notowań GPW w Linuksie oraz wyświetlanie ich w Conky

W ostatnim poście na temat monitora systemu Conky wspomniałem, że za niedługo pojawi się kolejny wpis na ten temat i słowa dotrzymałem :-) Dzisiaj pokażę jak prostym skryptem można pobrać notowania głównych indeksów Giełdy Papierów Wartościowych (WIG, WIG20, mWIG40, sWIG80) i jak ładnie wyświetlić je w wprost na pulpicie Linuksa za pośrednictwem Conky.

Read more
Back to top