Moving to namespaces

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Moving to namespaces

Post by MichaelC » Mon Dec 17, 2012 9:00 pm

During Amsterdam it was agreed that we should start using namespaces.

If this is going to be done it probably needs to be done in 3.1 otherwise we will be breaking BC.

Conventions
We should be following PSR-0

There would need to be coding guidelines added with regards to this and the use of use statements https://github.com/php-fig/fig-standard ... clarations and https://github.com/php-fig/fig-standard ... lass-names

Vendor name should be phpBB (That is what we have been using in other sub-projects already for a while).

Must be fully qualified as: \phpBB\<directories\from\includes>\<Class Name>

Underscores are treated as directory seperators so directory structures must be updated accordingly.

Example: phpbb_extension_metadata_manager must now be located in phpBB/includes/extension/metadata/manager.php would have the namespace \phpBB\extension\metadata_manager or \phpBB\extension\metadata\manager. This looks very weird due to our currently casing rules. As such as part of this RFC I propose that all new classes should be StudlyCaps in which case it would become \phpBB\Extension\MetadataManager and methods become camelCase.

Autoloading

We could probably use a library for our autoloader as well instead of updating our current one. The two options I see we have are using composer's autoloading and symfony autoloader. Both use FIG's PSR-0 standard.

There isn't much difference between them, composer was based upon symfony's universal class loader. http://stackoverflow.com/questions/1389 ... autoloader

Symfony Autoloader: https://github.com/symfony/ClassLoader & http://symfony.com/doc/current/componen ... oader.html
Composer Autoloader: https://github.com/composer/composer/tr ... r/Autoload
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Moving to namespaces

Post by igorw » Mon Dec 17, 2012 11:09 pm

IMO we should decouple the StudlyCaps discussion from the namespaces discussion, as they are two separate decisions. And presenting them as a package may be harmful.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Moving to namespaces

Post by MichaelC » Mon Dec 17, 2012 11:12 pm

If we are going to change the name of all classes, we might as well do it once and do 2 things than twice?
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Moving to namespaces

Post by Oleg » Mon Dec 17, 2012 11:33 pm

MichaelC wrote: If this is going to be done it probably needs to be done in 3.1 otherwise we will be breaking BC.
If this is the only reason I would prefer 3.1 to be left alone and this moved to 3.2.

If you are looking for something to do, may I suggest https://area51.phpbb.com/phpBB/viewtopi ... 19#p249219?

There should not be any new major features started at this point, and I don't want to ask pending patches to adopt this either.

Edit: both studly caps and namespaces.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Moving to namespaces

Post by MichaelC » Mon Dec 17, 2012 11:39 pm

Oleg wrote:
MichaelC wrote: If this is going to be done it probably needs to be done in 3.1 otherwise we will be breaking BC.
If this is the only reason I would prefer 3.1 to be left alone and this moved to 3.2.

If you are looking for something to do, may I suggest https://area51.phpbb.com/phpBB/viewtopi ... 19#p249219?

There should not be any new major features started at this point, and I don't want to ask pending patches to adopt this either.

Edit: both studly caps and namespaces.
It isn't a major feature. It would just be a large diff due to changing all instances of class names?

It's just that if we don't do this for 3.1 then it will probably wait until 4.0 as it will be a massive BC break?
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Moving to namespaces

Post by imkingdavid » Tue Dec 18, 2012 12:18 am

I vote no for 3.1 as well. This will only push back the release further still.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Moving to namespaces

Post by igorw » Tue Dec 18, 2012 1:41 am

One thing that was not mentioned in this topic is what the original motivation for namespaces was, which we discussed in amsterdam.

The problem with our current autoloading is that currently directory names for classes cannot contain any underscores. And that will be a problem for extensions, because a name like 'who_was_here' becomes 'whowashere'. Namespaces are the cleanest solution to that problem.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Moving to namespaces

Post by Oleg » Tue Dec 18, 2012 1:52 am

Fixing our autoloader sounds like an easier task. I'm assuming our present behavior is for efficiency reasons?

Is the reason why we initially did not go with namespaces that we were targeting 5.2?

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Moving to namespaces

Post by Oleg » Tue Dec 18, 2012 2:10 am

MichaelC wrote: It isn't a major feature. It would just be a large diff due to changing all instances of class names?
You are going to break all outstanding PRs with this just as we are trying to get them finished.

Are you willing to write a patch before it is decided whether it will go into 3.1 or 3.2?

Amsterdam happened over a month ago. If this RFC is important someone should have posted it in mid-November. Anything else you discussed that should have been RFCed and was not?

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Moving to namespaces

Post by MichaelC » Tue Dec 18, 2012 8:41 pm

Oleg wrote:
MichaelC wrote: It isn't a major feature. It would just be a large diff due to changing all instances of class names?
You are going to break all outstanding PRs with this just as we are trying to get them finished.

Are you willing to write a patch before it is decided whether it will go into 3.1 or 3.2?

Amsterdam happened over a month ago. If this RFC is important someone should have posted it in mid-November. Anything else you discussed that should have been RFCed and was not?
Sure but I have no idea how long it will take me to write the patch and test it and therefore whether it will be done for 3.1. ;) It isn't so much complicated as time-consuming going through all the classes. Then checking everything works afterwards.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Post Reply