Chris Steipp submitted a patch add namespaces to the OAuth extension
[0] in order to fix a compatibility issue with HHVM [1]. This change
led to a bit of bikeshedding on the proper namespace to use for the
extension. Chris initially chose `MWOAuth` but later amended to use
`MediaWiki\Extensions\OAuth` at my suggestion.
There is some discussion in gerrit, but my primary arguments were made
in irc (and in an unlogged channel no less), so I thought this topic
would be worth dragging out in front of everyone for a little debate.
I don't know of anyone who is actively trying to change MediaWiki core
to use namespaces, but extensions are using them. This leads me to
think that we should think as a group about the "right way" to use
namespaces and how to chose namespaces.
I suggested MediaWiki\Extensions\OAuth because it seems like the most
natural naming to me. PSR-4 [2] is very opinionated about namespaces.
It requires a top-level (or vendor) namespace. I chose "MediaWiki"
because ... MediaWiki. Beyond that sub-namespaces are optional, but
the file system path from the base directory to the php file must
match. Assuming that $IP is the base directory led me to suggest
MediaWiki\Extensions\OAuth.
The loudest argument I've heard here (and elsewhere) about using
namespaces like MediaWiki\Extensions\OAuth is that there are too many
characters to type. This, in my opinion, is really a we-fear-change
argument. With full PSR-4 namespacing, the longest fully qualified
class name would be
"MediaWiki\Extensions\OAuth\Frontend\SpecialPages\SpecialMWOAuthConsumerRegistration.php"
[3]. I will give no argument that this is a short string. I will say
however that I spent enough of my career working in java [4] on a
codebase with fully qualified class names like
"org.accessidaho.apps.itd.dlr.common.pLAZma_RestrictionModel" [5] to
find out two things: you typically type a fully qualified class name
once per file at most, and any reasonable editor can be configured to
have tab completion and/or macro expansion for commonly typed strings.
[0]:
https://gerrit.wikimedia.org/r/#/c/141608/
[1]:
https://bugzilla.wikimedia.org/show_bug.cgi?id=66929
[2]:
http://www.php-fig.org/psr/psr-4/
[3]: This could be shortened a bit by removing the embedded pseudo-namespacing
[4]: "A witch! Burn him!"
[5]: Not meant as an example of a good classname
Bryan
--
Bryan Davis Wikimedia Foundation <bd808(a)wikimedia.org>
[[m:User:BDavis_(WMF)]] Sr Software Engineer Boise, ID USA
irc: bd808 v:415.839.6885 x6855