Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On 17.05.2012, 2:36 Jeroen wrote:
Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P Seriously though, I think we should start slowly, maybe not including namespaces in 1.20 and then tread carefully - some extension devs might want to be compatible with older MW versions that support PHP 5.2.
On Wed, 16 May 2012 15:52:44 -0700, Max Semenik maxsem.wiki@gmail.com wrote:
On 17.05.2012, 2:36 Jeroen wrote:
Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P Seriously though, I think we should start slowly, maybe not including namespaces in 1.20 and then tread carefully - some extension devs might want to be compatible with older MW versions that support PHP 5.2.
I don't think we should use namespaces at all unless there is a good reason for it.
The only case I think we should allow namespaces in is within a MediaWiki component with a lot of small classes related to the component.
On Wed, May 16, 2012 at 4:03 PM, Daniel Friesen lists@nadir-seen-fire.comwrote:
On Wed, 16 May 2012 15:52:44 -0700, Max Semenik maxsem.wiki@gmail.com wrote:
On 17.05.2012, 2:36 Jeroen wrote:
Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in
MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P Seriously though, I think we should start slowly, maybe not including namespaces in 1.20 and then tread carefully - some extension devs might want to be compatible with older MW versions that support PHP 5.2.
I don't think we should use namespaces at all unless there is a good reason for it.
The only case I think we should allow namespaces in is within a MediaWiki component with a lot of small classes related to the component.
Well namespaces can provide for better organization, readability and dependency tracking among other things. So, it's probably worth investigating this a bit more.
-- ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
______________________________**_________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/wikitech-lhttps://lists.wikimedia.org/mailman/listinfo/wikitech-l
On May 16, 2012, at 3:52 PM, Max Semenik wrote:
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P
Ahh the namespace separator!
https://wiki.php.net/rfc/namespaceseparator
Brings back memories.
Hmm, Now that you mention it maybe we should have used ":P" as the namespace separator. ;-)
( I miss ":)" That would have made PHP a much happier place. It already has a lot of money ($), now it just needs some smileys.)
The namespace separator might be ugly, but it's in good company with the rest of the syntax of PHP.
- Trevor
On Wed, May 16, 2012 at 4:48 PM, Terry Chay tchay@wikimedia.org wrote:
On May 16, 2012, at 3:52 PM, Max Semenik wrote:
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P
Ahh the namespace separator!
https://wiki.php.net/rfc/namespaceseparator
Brings back memories.
Hmm, Now that you mention it maybe we should have used ":P" as the namespace separator. ;-)
( I miss ":)" That would have made PHP a much happier place. It already has a lot of money ($), now it just needs some smileys.) _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Dmitriy Sintsov.
Actually dollar sign as variable name prefix comes from Perl, which was very popular language during PHP3 / PHP4 time. The authors of PHP probably wanted to simplify Perl to PHP porting.
17 Май 2012 г. 3:48:55 пользователь Terry Chay (tchay@wikimedia.org) написал
On May 16, 2012, at 3:52 PM, Max Semenik wrote:
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P
Ahh the namespace separator!
https://wiki.php.net/rfc/namespaceseparator
Brings back memories.
Hmm, Now that you mention it maybe we should have used ":P" as the namespace separator. ;-)
( I miss ":)" That would have made PHP a much happier place. It already has a lot of money ($), now it just needs some smileys.)
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Wed, May 16, 2012 at 6:52 PM, Max Semenik maxsem.wiki@gmail.com wrote:
Frankly, the namespace syntax in PHP is so atrocitous that I would like to never see namespaces in out code:P Seriously though, I think we should start slowly, maybe not including namespaces in 1.20 and then tread carefully - some extension devs might want to be compatible with older MW versions that support PHP 5.2.
I agree. I think the syntax was completely batshit, and it makes me cringe whenever I see it. Don't expect me to use them ;-)
That being said, I don't see any real harm in writing up some guidelines if extensions want to use them--but please let's tread carefully here. Shiny new features are not always better features.
-Chad
On 17 May 2012 01:36, Jeroen De Dauw jeroendedauw@gmail.com wrote:
Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
I just came across to a reference to PSR-0 while researching another unrelated thing. Little bit of googling gives this: https://gist.github.com/1234504
Seems to be somewhat relevant to this discussion, although pretty much incompatible with what we do in MediaWiki currently. -Niklas
We probably should consider prefixing TLD classes (like SPL Iterators and such) with a \ just to be compatible with namespacing down the road.
On May 17, 2012, at 3:13 AM, Niklas Laxström wrote:
On 17 May 2012 01:36, Jeroen De Dauw jeroendedauw@gmail.com wrote:
Hey,
I am not aware of any guidelines regarding the usage of PHP namespaces in MediaWiki and di not find any on MediaWiki.org. Not surprising since 1.20 is the first release in which we can actually use it. So I'm curious on peoples thoughts on how to use this new features, if at all, in core and in extensions. As far as I get it, we cannot simply put it into core without breaking compat all over he place, but could gradually introduce it for new components. For new extensions it's a lot easier of course, which happens to be the use case I'm currently facing, and wondering what to best do. MediaWiki\ExtensionName seems like a reasonable NS for extension classes.
I just came across to a reference to PSR-0 while researching another unrelated thing. Little bit of googling gives this: https://gist.github.com/1234504
Seems to be somewhat relevant to this discussion, although pretty much incompatible with what we do in MediaWiki currently. -Niklas
-- Niklas Laxström
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
An initial \ is only necessary if you add a namespace to the top of the file.
Changing a class to use a namespace also completely changes it's class name and breaks all code depending on that class, namely extensions. And there is absolutely no good reason to add a namespace to existing code strong enough to outweigh the fact that we'll be breaking extensions.
So I see absolutely no reason to go adding \ into files.
Hmm maybe technically. But the way namespaces are implemented in PHP 5.3 is very simple (that's part of the reason they chose the forward slash separator). HipHop can be easily upgraded to support it… if it hasn't been done already.
I guess the only sure way is to compile some test scripts in HH. There might be some edge cases they missed. :-)
On May 17, 2012, at 9:59 AM, Platonides wrote:
Wouldn't that make it incompatible with hiphop?
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Thu, May 17, 2012 at 10:11 AM, Terry Chay tchay@wikimedia.org wrote:
Hmm maybe technically. But the way namespaces are implemented in PHP 5.3 is very simple (that's part of the reason they chose the forward slash separator).
I think you mean the *backslash* () character.
HipHop can be easily upgraded to support it… if it hasn't been done already.
I guess the only sure way is to compile some test scripts in HH. There might be some edge cases they missed. :-)
On May 17, 2012, at 9:59 AM, Platonides wrote:
Wouldn't that make it incompatible with hiphop?
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On May 17, 2012, at 10:25 AM, Patrick Reilly wrote:
On Thu, May 17, 2012 at 10:11 AM, Terry Chay tchay@wikimedia.org wrote:
Hmm maybe technically. But the way namespaces are implemented in PHP 5.3 is very simple (that's part of the reason they chose the forward slash separator).
I think you mean the *backslash* () character.
Yes.
I'm specifically referring to the fact that global namespacing is automatic in the case of functions, but not in the case of classes themselves. So things like stdClass need to be \stdClass IF at a later point you decide to put a topline namespace in front of the file.
If we're really 5.3 only, then it can't hurt to do that for built-in classes now.
If we're not, then this breaks BC with 5.2
wikitech-l@lists.wikimedia.org